Oracle 10g RAC OCR 和 VotingDisk 的備份與恢複

來源:互聯網
上載者:User

標籤:

 

Oracle RAC 中OCR 和Voting Disk 備份在我的blog: Oracle RAC 常用維護工具和命令 中已經有說明,現在再次把它單獨拿出做一個說明, 因為OCR 和Voting Disk 對於RAC 系統來說太重要了。

 

Oracle RAC 常用維護工具和命令

http://blog.csdn.net/tianlesoftware/archive/2010/03/09/5358573.aspx

 

.  Voting Disk

Voting Disk 這個檔案主要用於記錄節點成員狀態,在出現腦裂時,決定那個Partion獲得控制權,其他的Partion必須從叢集中剔除。Voting disk使用的是一種“多數可用演算法”,如果有多個Voting  disk,,則必須一半以上的Votedisk同時使用,Clusterware才能正常使用。 比如配置了4個Votedisk,壞一個Votedisk,叢集可以正常工作,如果壞了2個,則不能滿足半數以上,叢集會立即宕掉,所有節點立即重啟,所以如果添加Votedisk,盡量不要只添加一個,而應該添加2個。這點和OCR 不一樣。OCR 只需配置一個。

 

查看votedisk的位置:

[[email protected] ~]# crsctl query css votedisk

0.    0   /dev/raw/raw2

located 1 votedisk(s).

 

備份votedisk盤:

[[email protected] bin]# dd if=/dev/raw/raw2 of=/home/oracle/voting_disk.bak

294912+0 records in

294912+0 records out

 

恢複votedisk盤:

[[email protected] bin]# dd if=/home/oracle/voting_disk.bak of=/dev/raw/raw2

294912+0 records in

294912+0 records out

 

通過Strings 命令來查看 voting disk 的內容

[[email protected] oracle]# strings voting_disk.bak |sort -u

fSLC

ssLckcoT

SslcLlik

sSlcrEp0

}|{z

 

 

 .  OCR

 

Oracle Clusterware把整個叢集的配置資訊放在共用儲存上,這些資訊包括了叢集節點的列表、叢集資料庫執行個體到節點的映射以及CRS應用程式資源資訊。存放的位置就在OCR Disk上. 在整個叢集中,只有一個節點能對OCR Disk 進行讀寫操作,這個節點叫作Master Node,所有節點都會在記憶體中保留一份OCR的拷貝,同時有一個OCR Process 從這個記憶體中讀取內容。 OCR 內容發生改變時,由Master Node的OCR Process負責同步到其他節點的OCR Process。

 

因為OCR的內容如此重要,所以Oracle 每4個小時對其做一次備份,並且保留最後的3個備份,以及前一天,前一周的最後一個備份。 這個備份由Master Node CRSD進程完成,備份的預設位置是$CRS_HOME/crs/cdata/<cluster_name>目錄下,可以通過ocrconfig -backuploc <directory_name> 命令修改到新的目錄。每次備份後,備份檔案名自動更改,以反應備份時間順序,最近一次的備份叫作backup00.ocr。這些備份檔案除了儲存在本地,DBA還應該在其他存放裝置上保留一份,以防止意外的儲存故障。

 

[[email protected] crs]# pwd

/u01/app/oracle/product/crs/cdata/crs

[[email protected] crs]# ls -lrt

total 22632

-rw-r--r--  1 root root 4595712 Mar  9 01:03 backup02.ocr

-rw-r--r--  1 root root 4620288 Mar  9 21:20 backup01.ocr

-rw-r--r--  1 root root 4632576 Apr  8 19:46 backup00.ocr

-rw-r--r--  1 root root 4632576 Apr  8 19:46 day.ocr

-rw-r--r--  1 root root 4632576 Apr  8 19:46 week.ocr

 

 

在安裝clusterware過程中,如果選擇External Redundancy冗餘方式,則只能輸入一個OCR磁碟位置。 但是Oracle允許配置兩個OCR 磁碟互為鏡像,以防止OCR 磁碟的單點故障。 OCR 磁碟和Votedisk磁碟不一樣,OCR磁碟最多隻能有兩個,一個Primary OCR 和一個Mirror OCR。

 

Oracle 推薦在對叢集做調整時,比如增加,刪除節點之前,修改RAC IP之前,對OCR做一個備份,可以使用export 備份到指定檔案,如果做了replace或者restore 等操作,Oracle 建議使用 cluvfy comp ocr -n all 命令來做一次全面的檢查。對OCR的備份與恢複,我們可以使用ocrconfig 命令。

 

[[email protected] bin]# ./ocrconfig --help

Name:

        ocrconfig - Configuration tool for Oracle Cluster Registry.

Synopsis:

        ocrconfig [option]

        option:

                -export <filename> [-s online]

                                                    - Export cluster register contents to a file

                -import <filename>                  - Import cluster registry contents from a file

                -upgrade [<user> [<group>]]

                                                    - Upgrade cluster registry from previous version

                -downgrade [-version <version string>]

                                                    - Downgrade cluster registry to the specified version

                -backuploc <dirname>                - Configure periodic backup location

                -showbackup                         - Show backup information

                -restore <filename>                 - Restore from physical backup

                -replace ocr|ocrmirror [<filename>] - Add/replace/remove a OCR device/file

                -overwrite                          - Overwrite OCR configuration on disk

                -repair ocr|ocrmirror <filename>    - Repair local OCR configuration

                -help                               - Print out this help information

Note:

        A log file will be created in

        $ORACLE_HOME/log/<hostname>/client/ocrconfig_<pid>.log. Please ensure

        you have file creation privileges in the above directory before

        running this tool.

 

 

1.  用匯出匯入備份恢複OCR

 

1) 首先關閉所有節點的CRS

[[email protected] bin]# ./crsctl stop crs

Stopping resources.

Successfully stopped CRS resources

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.

 

2) 用root 使用者匯出OCR內容

[[email protected] bin]# ./ocrconfig -export /u01/ocr.exp

 

3) 重啟CRS

[[email protected] bin]# ./crsctl start crs

Attempting to start CRS stack

The CRS stack will be started shortly

 

4) 檢查CRS 狀態

[[email protected] bin]# ./crsctl check crs

CSS appears healthy

CRS appears healthy

EVM appears healthy

 

5)破壞OCR內容

[[email protected] bin]# dd if=/dev/zero of=/dev/raw/raw1 bs=1024 count=102400

102400+0 records in

102400+0 records out

 

6) 檢查OCR一致性

[[email protected] bin]# ./ocrcheck

PROT-601: Failed to initialize ocrcheck

 

7)使用cluvfy 工具檢查一致性

[[email protected] cluvfy]# ./runcluvfy.sh comp ocr -n all

Verifying OCR integrity

Unable to retrieve nodelist from Oracle clusterware.

Verification cannot proceed.

 

8) 使用Import 恢複OCR 內容

[[email protected] bin]# ./ocrconfig -import /u01/ocr.exp

 

注意:  使用restore選項只能匯入OCR自動產生的物理備份,

         import選項只能匯入通過export選項匯出的的邏輯備份。

 

9)再次檢查OCR

[[email protected] bin]# ./ocrcheck

Status of Oracle Cluster Registry is as follows :

         Version               :          2

         Total space (kbytes)     :     147352

         Used space (kbytes)    :       4364

         Available space (kbytes) :     142988

         ID                    :  610419116

         Device/File Name        : /dev/raw/raw1

                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

 

10) 使用cluvfy工具檢查

[[email protected] cluvfy]# ./runcluvfy.sh comp ocr -n all

 

 

2. 自動備份恢複OCR

 

(1)關閉運行在叢集資料庫的所有節點上的CRS服務程式

        /etc/init.d/init.crs stop

在Oracle 11gR2 中已經沒有了init.crs 命令了。 只能通過

       #crsctl stop crs

命令來關閉CRS.

 

(2). 通過ocrconfig 的showbackup選項查看最近的備份

 

[[email protected] ~]# ocrconfig -showbackup

racnode1     2010/11/22 13:30:27     /u01/app/11.2.0/grid/cdata/racnode-cluster/backup00.ocr

racnode1     2010/11/22 09:30:27     /u01/app/11.2.0/grid/cdata/racnode-cluster/backup01.ocr

racnode1     2010/11/22 05:30:26     /u01/app/11.2.0/grid/cdata/racnode-cluster/backup02.ocr

racnode1     2010/11/21 05:30:23     /u01/app/11.2.0/grid/cdata/racnode-cluster/day.ocr

racnode1     2010/11/11 03:35:10     /u01/app/11.2.0/grid/cdata/racnode-cluster/week.ocr

 

(3)通過ocrconfig的restore或import選項匯入OCR資料

ocrconfig  -restore  filename_location                          

如:

ocrconfig  -restore  /u01/app/11.2.0/grid/cdata/racnode-cluster/backup00.ocr

 

注意:  使用restore選項只能匯入OCR自動產生的物理備份,

         import選項只能匯入通過export選項匯出的的邏輯備份。

 

(4) 檢查CRS

[[email protected] bin]# ./ocrcheck

 

使用cluvfy工具檢查

[[email protected] cluvfy]# ./runcluvfy.sh comp ocr -n all

 

 

(5)在所有節點上重新啟動CRS                                               

      /etc/init.d/init.crs   start

 

在Oracle 11gR2使用:#crsctl start crs 命令來啟動CRS.

 

 

 

小結:

       這裡只提到了OCR 和Voting Disk 的備份。 實際上,對於一個資料庫環境來說,要備份的東西還有很多。  只不過OCR這東西涉及RAC 底層的東西,所以在做涉及OCR的變更之前要非常小心。  做操作之前,最好是手工的用ocrconfig -export 把OCR 備份一下。

 

       對於一個資料庫環境,還需要的備份的東西如:spfile,control file,資料檔案位置等。 資料檔案位置,可用如下命令查看:

       elect file_name,tablespace_name from dba_data_files;

       select file_name,tablespace_name from dba_temp_files;

       有時候在恢複的時候需要這些資訊。 我們盡量備份多一點,這樣對恢複就越有利。  

 

以前對DBA的認識:

       1. 膽大心細,遇事不慌

       2. 制定完善的備份策略,做相關操作之前,也是需要備份。

       3. 做變更之前,要先整理出文檔,按照文檔操作。 在好的記憶和經驗也難免有遺漏的時候,照文檔來,一步一步操作。

 

 

那天和群裡 布豆 討論的時候,他說了一條:

       風險大的事情不做,變個思路將風險降低到最低點再操作!

轉:http://blog.csdn.net/tianlesoftware/article/details/5467273

Oracle 10g RAC OCR 和 VotingDisk 的備份與恢複

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.