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

season0891發表於2010-08-31

原創  Oracle 10g RAC OCR 和 VotingDisk 的備份與恢復 收藏

300) { text = text + "\r\n\n本文來自CSDN部落格,轉載請標明出處:" + location.href; clipboardData.setData("text", text); } }, 100); } }

 

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才能正常使用。 比如配置了4Votedisk,壞一個Votedisk,叢集可以正常工作,如果壞了2個,則不能滿足半數以上,叢集會立即宕掉,所有節點立即重啟,所以如果新增Votedisk,儘量不要只新增一個,而應該新增2個。這點和OCR 不一樣。OCR 只需配置一個。

檢視votedisk的位置:

[root@rac1 ~]# crsctl query css votedisk

0.    0   /dev/raw/raw2

located 1 votedisk(s).

備份votedisk盤:

[root@raw1 bin]# dd if=/dev/raw/raw2 of=/home/oracle/voting_disk.bak

294912+0 records in

294912+0 records out

恢復votedisk盤:

[root@raw1 bin]# dd if=/home/oracle/voting_disk.bak of=/dev/raw/raw2

294912+0 records in

294912+0 records out

透過Strings 命令來檢視 voting disk 的內容

[root@raw1 oracle]# strings voting_disk.bak |sort -u

fSLC

ssLckcoT

SslcLlik

sSlcrEp0

}|{z

 

  OCR 

Oracle Clusterware把整個叢集的配置資訊放在共享儲存上,這個儲存就是OCR Disk. 在整個叢集中,只有一個節點能對OCR Disk 進行讀寫操作,這個節點叫作Master Node,所有節點都會在記憶體中保留一份OCR的複製,同時一個OCR Process 從這個記憶體中讀取內容。 OCR 內容發生改變時,由Master NodeOCR Process負責同步到其他節點的OCR Process。 

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

[root@raw1 crs]# pwd

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

[root@raw1 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 推薦在對叢集做調整時,比如增加,刪除節點之前,應該對OCR做一個備份,可以使用export 備份到指定檔案,如果做了replace或者restore 等操作,Oracle 建議使用 cluvfy comp ocr -n all 命令來做一次全面的檢查。OCR的備份與恢復,我們可以使用ocrconfig 命令。

[root@raw1 bin]# ./ocrconfig --help

Name:

        ocrconfig - Configuration tool for Oracle Cluster Registry.

Synopsis:

        ocrconfig [option]

        option:

                -export  [-s online]

                                                    - Export cluster register contents to a file

                -import                   - Import cluster registry contents from a file

                -upgrade [ []]

                                                    - Upgrade cluster registry from previous version

                -downgrade [-version ]

                                                    - Downgrade cluster registry to the specified version

                -backuploc                 - Configure periodic backup location

                -showbackup                         - Show backup information

                -restore                  - Restore from physical backup

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

                -overwrite                          - Overwrite OCR configuration on disk

                -repair ocr|ocrmirror     - Repair local OCR configuration

                -help                               - Print out this help information

Note:

        A log file will be created in

        $ORACLE_HOME/log//client/ocrconfig_.log. Please ensure

        you have file creation privileges in the above directory before

        running this tool.

OCR 備份與恢復

-- 檢視自助備份

[root@raw1 bin]# ./ocrconfig -showbackup

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

[root@raw1 bin]# ./crsctl stop crs

Stopping resources.

Successfully stopped CRS resources

Stopping CSSD.

Shutting down CSS daemon.

Shutdown request successfully issued.

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

[root@raw1 bin]# ./ocrconfig -export /u01/ocr.exp

3) 重啟CRS

[root@raw1 bin]# ./crsctl start crs

Attempting to start CRS stack

The CRS stack will be started shortly

4) 檢查CRS 狀態

[root@raw1 bin]# ./crsctl check crs

CSS appears healthy

CRS appears healthy

EVM appears healthy

5)破壞OCR內容

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

102400+0 records in

102400+0 records out

6) 檢查OCR一致性

[root@raw1 bin]# ./ocrcheck

PROT-601: Failed to initialize ocrcheck

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

[root@raw1 cluvfy]# ./runcluvfy.sh comp ocr -n all

Verifying OCR integrity

Unable to retrieve nodelist from Oracle clusterware.

Verification cannot proceed.

8) 使用Import 恢復OCR 內容

[root@raw1 bin]# ./ocrconfig -import /u01/ocr.exp

如果不用import , 使用恢復命令

[root@raw1 bin]# ./ocrconfig –restore $CRS_HOME/cdata/crs/自動備份.ocr

9)再次檢查OCR

[root@raw1 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工具檢查

[root@raw1 cluvfy]# ./runcluvfy.sh comp ocr -n all

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-672218/,如需轉載,請註明出處,否則將追究法律責任。

相關文章