[WK-T]ORACLE RAC +ASM Backup and Recovery(四)

dayong2015發表於2014-09-03
文章參考:http://blog.csdn.net/tianlesoftware/article/details/5467273
Oracle 10g RAC OCR 和 VotingDisk 的備份與恢復

一.  Voting Disk  表決盤
Oracle Clusterware由2部分組成,分別是Voting Disk和 OCR。Voting Disk裡面記錄著節點成員的資訊。如RAC資料庫中有哪些節點成員,節點增加或者刪除時也同樣會將資訊記錄進來。Voting Disk必須存放在共享儲存上,通常來說是存放在裸裝置上。Voting Disk主要為了在出現腦裂時,決定那個Partion獲得控制權,其他的Partion必須從叢集中剔除。為了保證Voting Disk的安全,需要配置多個Voting Disk,Voting disk使用的是一種“多數可用演算法”。當有多個Voting  disk時,則必須一半以上的Votedisk同時使用,Clusterware才能正常使用。 比如配置了4個Votedisk,壞一個Votedisk,叢集可以正常工作,如果壞了2個,則不能滿足半數以上,叢集會立即宕掉,所有節點立即重啟,所 以如果新增Votedisk,儘量不要只新增一個,而應該新增2個。Oracle建議Voting Disk的個數應該為奇數個。
1.檢視Votingdisk磁碟位置資訊
[oracle@rac1 ~]$ crsctl query css votedisk
 0.     0    /dev/raw/raw2

located 1 votedisk(s).
2.備份Votingdisk磁碟
[oracle@rac1 voting_bak]$ dd if=/dev/raw/raw2 of=/u01/app/backup/voting_bak/voting_disk.bak
401562+0 records in
401562+0 records out
205599744 bytes (206 MB) copied, 284.808 seconds, 722 kB/s
檢視備份檔案資訊:
[oracle@rac1 voting_bak]$ ll
total 200988
-rw-r--r-- 1 oracle oinstall 205599744 Sep  3 16:19 voting_disk.bak
檢視備份檔案內容資訊:
[oracle@rac1 ~]$ strings /u01/app/backup/voting_bak/voting_disk.bak |sort -u
fSLC
ssLckcoT
SslcLlik
sSlcrEp0
}|{z
3.在需要的時候對Voting disk進行恢復
[oracle@rac1 ~]$ dd if=/u01/app/backup/voting_bak/voting_disk.bak of=/dev/raw2
dd: opening `/dev/raw2': Permission denied
[oracle@rac1 ~]$ su - root
Password:
[root@rac1 ~]# dd if=/u01/app/backup/voting_bak/voting_disk.bak of=/dev/raw2
401562+0 records in
401562+0 records out
205599744 bytes (206 MB) copied, 0.921637 seconds, 223 MB/s
二.OCR(oracle cluster register)  叢集登錄檔
OCR 負責維護整個叢集的配置資訊,包括RAC以及Clusterware資源,包括的資訊有節點成員、資料庫、例項、服務、監聽器、應用程式等。為了解決叢集
的“健忘”問題,整個叢集會有一份配置OCR,最多兩分OCR,一個primary OCR和一個mirror OCR互為映象,以防OCR的單點故障。叢集中的其中一個Oracle
Clusterware例項(CRSD例項)每四小時就會自動建立OCR備份,CRS會保留最後三個副本,此外,該CRSD程式還會在每天和每週開始時建立OCR備份,並保
留最後兩個副本。這個備份由Master Node的CRSD程式完成,備份的預設位置為$CRS_HOME/crs/cdata/目錄下。每次備份後, 備份檔案
的名字會自動變更,以反映備份時間順序,最近一次備份叫做backup00.ocr。為了保證更好的安全性,應每天將OCR自動備份到其他儲存裝置上,在進行
重大更改(如新增/刪除節點、修改oracle clusterware資源或建庫)之前和之後應對OCR進行邏輯備份,確保還原與當前系統配置相匹配的OCR備份。
1.檢視OCR的自動備份檔案資訊
[oracle@rac1 ~]$ ocrconfig -showbackup
rac1     2014/09/03 13:04:44     /u01/app/oracle/crs/cdata/crs
rac1     2014/09/01 13:00:02     /u01/app/oracle/crs/cdata/crs
rac1     2014/09/01 09:00:01     /u01/app/oracle/crs/cdata/crs
rac1     2014/09/03 13:04:44     /u01/app/oracle/crs/cdata/crs
rac2     2014/08/25 12:58:15     /u01/app/oracle/crs/cdata/crs
[oracle@rac1 crs]$ pwd
/u01/app/oracle/crs/cdata/crs
[oracle@rac1 crs]$ ll
total 23080
-rw-r--r-- 1 root root 4714496 Sep  3 13:04 backup00.ocr
-rw-r--r-- 1 root root 4714496 Sep  1 13:00 backup01.ocr
-rw-r--r-- 1 root root 4714496 Sep  1 09:00 backup02.ocr
-rw-r--r-- 1 root root 4714496 Sep  3 13:04 day.ocr
-rw-r--r-- 1 root root 4714496 Sep  1 05:00 week_.ocr
2.使用匯出匯入備份OCR
1)檢視OCR的磁碟資訊
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     200692
         Used space (kbytes)      :       4052
         Available space (kbytes) :     196640
         ID                       : 1469118214
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded
2)首先關閉所有節點的CRS
[root@rac1 ~]# /u01/app/oracle/crs/bin/crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
3)root使用者匯出OCR內容
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrconfig -export /u01/app/backup/ocr_bak/ocr.exp
[root@rac1 ~]# cd  /u01/app/backup/ocr_bak/
[root@rac1 ocr_bak]# ll
total 96
-rw-r--r-- 1 root root 91260 Sep  3 17:26 ocr.exp
4)重啟CRS
[root@rac1 ocr_bak]# /u01/app/oracle/crs/bin/crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
5)檢查CRS狀態
[root@rac1 ocr_bak]# /u01/app/oracle/crs/bin/crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
6)破壞OCR內容
[root@rac1 ~]# dd if=/dev/zero of=/dev/raw/raw1 bs=200M count=1000
dd: writing `/dev/raw/raw1': No space left on device
1+0 records in
0+0 records out
205599744 bytes (206 MB) copied, 1.4783 seconds, 139 MB/s
7)檢查OCR一致性
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrcheck
PROT-601: Failed to initialize ocrcheck
8)使用cluvfy 工具檢查一致性
[root@rac1 ~]# /u01/app/oracle/crs/bin/cluvfy comp ocr -n all

Verifying OCR integrity
Unable to retrieve nodelist from Oracle clusterware.

Verification cannot proceed.
9)使用import修復OCR內容
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrconfig -import /u01/app/backup/ocr_bak/ocr.exp
批註:使用restore選項只能匯入OCR自動產生的物理備份,import選項只能匯入透過export選項匯出的的邏輯備份。
10)再次檢查OCR磁碟資訊
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     200692
         Used space (kbytes)      :       4052
         Available space (kbytes) :     196640
         ID                       :   69183330
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded
11)再次使用cluvfy 工具檢查一致性
[root@rac1 ~]# /u01/app/oracle/crs/bin/cluvfy comp ocr -n all

Verifying OCR integrity

ERROR:
User equivalence unavailable on all the nodes.
Verification cannot proceed.

Verification of OCR integrity was unsuccessful on all the nodes.
[oracle@rac1 ~]$ /u01/app/oracle/crs/bin/cluvfy comp ocr -n all          --切換到oracle使用者執行,成功

Verifying OCR integrity

Checking OCR integrity...

Checking the absence of a non-clustered configuration...
All nodes free of non-clustered, local-only configurations.

Uniqueness check for OCR device passed.

Checking the version of OCR...
OCR of correct Version "2" exists.

Checking data integrity of OCR...
Data integrity check for OCR passed.

OCR integrity check passed.

Verification of OCR integrity was successful.
3.自動備份恢復OCR
1).關閉CRS服務程式
[root@rac1 ~]# /u01/app/oracle/crs/bin/crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
2)透過ocrconfig的showbackup選項檢視最近的備份
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrconfig -showbackup
rac1     2014/09/03 17:04:45     /u01/app/oracle/crs/cdata/crs
rac1     2014/09/03 13:04:44     /u01/app/oracle/crs/cdata/crs
rac1     2014/09/01 13:00:02     /u01/app/oracle/crs/cdata/crs
rac1     2014/09/03 13:04:44     /u01/app/oracle/crs/cdata/crs
rac2     2014/08/25 12:58:15     /u01/app/oracle/crs/cdata/crs
3)透過ocrconfig的restore或import選項匯入OCR資料
語法:ocrconfig  -restore  filename_location
[root@rac1 ~]# cd /u01/app/oracle/crs/cdata/crs
[root@rac1 crs]# ll
total 23080
-rw-r--r-- 1 root root 4714496 Sep  3 17:04 backup00.ocr
-rw-r--r-- 1 root root 4714496 Sep  3 13:04 backup01.ocr
-rw-r--r-- 1 root root 4714496 Sep  1 13:00 backup02.ocr
-rw-r--r-- 1 root root 4714496 Sep  3 13:04 day.ocr
-rw-r--r-- 1 root root 4714496 Sep  3 17:04 week_.ocr
[root@rac1 crs]# cd ~
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrconfig -restore /u01/app/oracle/crs/cdata/crs/backup00.ocr
4)檢查CRS
[root@rac1 ~]# /u01/app/oracle/crs/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     200692
         Used space (kbytes)      :       4044
         Available space (kbytes) :     196648
         ID                       :   69183330
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded
使用cluvfy工具檢查
[oracle@rac1 ~]$ /u01/app/oracle/crs/bin/cluvfy comp ocr -n all

Verifying OCR integrity

Checking OCR integrity...

Checking the absence of a non-clustered configuration...
All nodes free of non-clustered, local-only configurations.

Uniqueness check for OCR device passed.

Checking the version of OCR...
OCR of correct Version "2" exists.

Checking data integrity of OCR...
Data integrity check for OCR passed.

OCR integrity check passed.

Verification of OCR integrity was successful.
5)在節點上重啟CRS服務
[root@rac1 ~]# /u01/app/oracle/crs/bin/crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly

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

相關文章