管理OCR與VoteDisk-創(chuàng)新互聯(lián)

Oracle Clusterware由2部分組成,分別是Voting Disk和OCR。Voting Disk里面記錄著節(jié)點(diǎn)成員的信息。如RAC數(shù)據(jù)庫(kù)中有哪些節(jié)點(diǎn)成員,節(jié)點(diǎn)增加或者刪除時(shí)也同樣會(huì)將信息記錄進(jìn)來(lái)。Voting Disk必須存放在共享存儲(chǔ)上,通常來(lái)說(shuō)是存放在裸設(shè)備上。為了保證Voting Disk的安全,需要配置多個(gè)Voting Disk,Oracle建議Voting Disk的個(gè)數(shù)應(yīng)該為奇數(shù)個(gè),如 1、3、5個(gè),每個(gè)Voting Disk的大小約為20MB。
OCR記錄的是節(jié)點(diǎn)成員的配置信息,如數(shù)據(jù)庫(kù)、ASM、實(shí)例、監(jiān)聽(tīng)器、VIP等CRS資源的配置信息。CRS進(jìn)程管理的信息來(lái)自O(shè)CR的內(nèi)容。OCR存儲(chǔ)的配置信息是以目錄樹(shù)的形式來(lái)記錄一系列“鍵-值”對(duì)應(yīng)信息的。OCR記錄著CRS進(jìn)程管理資源的所有配置信息。大小約為100MB。
對(duì)Voting Disk的更改必須用root來(lái)進(jìn)行。
添加一個(gè)Voting Disk成員:crsctl add css votedisk /dev/raw/raw3'
刪除一個(gè)Voting Disk成員:crsctl delete css votedisk /dev/raw/raw3'

對(duì)OCR的增加、刪除和替代配置可以由root用戶通過(guò)ocrconfig -replace來(lái)操作:
ocrconfig -replace /dev/raw/raw1

注意:添加、刪除Voting Disk必須在線完成。

Voting Disk和OCR存放的信息是至關(guān)重要的,一旦他們丟失或者損壞的話,Clusterware將無(wú)法啟動(dòng),這樣整個(gè)RAC都無(wú)法啟動(dòng)。因此需要對(duì)Voting Disk和OCR進(jìn)行完備的備份。

對(duì)Voting Disk的備份操作可以通過(guò)dd命令來(lái)操作。
查看位置:
#crsctl query css votedisk
備份操作:
#dd if=/dev/raw/raw2 f=/home/oracle/voting_disk.bak
恢復(fù)操作:
#dd if=/home/oracle/voting_disk.bak f=/dev/raw/raw2

默認(rèn)情況下,RAC會(huì)在其中一個(gè)節(jié)點(diǎn)上每4個(gè)小時(shí)都自動(dòng)備份一次OCR。并保留最近的3次備份,另外還保留最近兩天以及最近兩個(gè)周末的備份。這個(gè)可以通過(guò)命令ocrconfig -showbackup來(lái)查看。由于ocr信息的重要性,OCR默認(rèn)會(huì)每4小時(shí)自動(dòng)備份一次ocr的內(nèi)存,保留最新的3個(gè)備份,還會(huì)保留最近2周周末的備份。備份默認(rèn)的備份路徑為$CRS_HOME/cdata/crs。可以通過(guò)ocrconfig -backuploc來(lái)更改OCR的備份路徑。OCR自動(dòng)備份的時(shí)間間隔無(wú)法修改。我們還可以通過(guò)ocrconfig -export 來(lái)到處OCR的內(nèi)容,也可以通過(guò)通過(guò)ocrconfig -import導(dǎo)入OCR的內(nèi)容。

可以用ocrconfig -restore 命令對(duì)OCR進(jìn)行恢復(fù)。
./ocrconfig -restore /u01/oracle/product/10g/crs/cdata/crs/backup00.ocr

添加Voting Disk:
[root@rhel1 bin]# ./crsctl add css votedisk /u01/ocfs2fs/vdisk2
Cluster is not in a ready state for online disk addition
[root@rhel1 bin]# ./crsctl add css votedisk /u01/ocfs2fs/vdisk2 -force
Now formatting voting disk: /u01/ocfs2fs/vdisk2
successful addition of votedisk /u01/ocfs2fs/vdisk2.

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了曲沃免費(fèi)建站歡迎大家使用!

chown oracle:oinstall /u01/ocfs2fs/vdisk2
chmod 775 /u01/ocfs2fs/vdisk2

[root@rhel1 bin]# /etc/init.crs start
[root@rhel1 bin]# ./crsctl query css votedisk
 0.     0    /u01/ocfs2fs/vdisk
 1.     0    /u01/ocfs2fs/vdisk2

注意:votedisk可以有多個(gè)成員。add voting disk必須是所有服務(wù)都關(guān)閉的情況下完成。創(chuàng)建的votedisk的個(gè)數(shù)應(yīng)該是奇數(shù),只有滿足一半以上的votedisk是正常的crs才能正常運(yùn)行。例如如果有4個(gè)votedisk,那么壞了1個(gè)可以正常運(yùn)行,壞了2個(gè)就不能正常運(yùn)行了。如果有5個(gè)的話,壞了3個(gè)就不能正常運(yùn)行了。

添加OCR鏡像:
[root@rhel1 bin]#
touch /u01/ocfs2fs/ocr2
[root@rhel1 bin]# ./ocrconfig -replace ocrmirror /u01/ocfs2fs/ocr2
[root@rhel1 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2756
         Available space (kbytes) :     259364
         ID                       : 2062708016
         Device/File Name         : /u01/ocfs2fs/ocr
                                    Device/File integrity check succeeded
         Device/File Name         : /u01/ocfs2fs/ocr2
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

注意:add ocr可以是在線完成。ocr最多只能有2個(gè),一個(gè)primary ocr,一個(gè)mirror ocr。

刪除OCR鏡像:
[root@rhel1 bin]# ./ocrconfig -replace ocrmirror
[root@rhel1 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2756
         Available space (kbytes) :     259364
         ID                       : 2062708016
         Device/File Name         : /u01/ocfs2fs/ocr
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

[root@rhel1 bin]# cat /etc/oracle/ocr.loc
#Device/file /u01/ocfs2fs/ocr2 being deleted
ocrconfig_loc=/u01/ocfs2fs/ocr

刪除Voting Disk:
[root@rhel1 bin]# ./crsctl delete css votedisk /u01/ocfs2fs/vdisk2
Cluster is not in a ready state for online disk removal
[root@rhel1 bin]# ./crsctl stop crs
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

[root@rhel1 bin]#
./crsctl delete css votedisk /u01/ocfs2fs/vdisk2
Cluster is not in a ready state for online disk removal
[root@rhel1 bin]# ./crsctl delete css votedisk /u01/ocfs2fs/vdisk2 -force
successful deletion of votedisk /u01/ocfs2fs/vdisk2.
[root@rhel1 bin]# ./crsctl query css votedisk
 0.     0    /u01/ocfs2fs/vdisk

located 1 votedisk(s).

備份、恢復(fù)Voting Disk:
[root@rhel1 bin]# ./crsctl check crs
Failure 1 contacting CSS daemon
Cannot communicate with CRS
Cannot communicate with EVM

[root@rhel1 bin]#
dd if=/u01/ocfs2fs/vdisk f=/home/oracle/vdisk_bak     //備份,ocfs2也可直接copy
20000+0 records in
20000+0 records out
10240000 bytes (10 MB) copied, 0.301106 seconds, 34.0 MB/s

[root@rhel1 bin]# rm -rf /u01/ocfs2fs/vdisk
[root@rhel1 bin]# dd if=/home/oracle/vdisk_bak f=/u01/ocfs2fs/vdisk     //恢復(fù),ocfs2也可直接copy
20000+0 records in
20000+0 records out
10240000 bytes (10 MB) copied, 0.173678 seconds, 59.0 MB/s

[root@rhel1 bin]# chown oracle:oinstall /u01/ocfs2fs/vdisk
[root@rhel1 bin]# chmod 775 /u01/ocfs2fs/vdisk
[root@rhel1 bin]# /etc/init.d/init.crs start
Startup will be queued to init within 30 seconds.
[root@rhel1 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

備份、恢復(fù)OCR:
備份:
我們?cè)趯?duì)集群做任何大的操作的時(shí)候,例如,Clusterware升級(jí)、環(huán)境遷移等都要對(duì)Votedisk和OCR進(jìn)行備份,上面介紹了Votedisk的備份方法,這里介紹一下有關(guān)OCR的備份和恢復(fù)。
OCR有一套自動(dòng)備份機(jī)制,包含如下的規(guī)則:
1.每4個(gè)小時(shí)自動(dòng)生成一份OCR備份,并保留最后3個(gè)備份。
2.CRSD進(jìn)程還會(huì)在每天開(kāi)始時(shí)生成OCR備份,并保留最后2個(gè)備份。
3.CRSD進(jìn)程還會(huì)在每周開(kāi)始時(shí)生成OCR備份,并保留最后2個(gè)備份。

請(qǐng)注意:OCR自動(dòng)備份只會(huì)保留在其中一個(gè)節(jié)點(diǎn),并不是每個(gè)節(jié)點(diǎn)都存在自動(dòng)備份。
通過(guò)OCRCONFIG可以查看到OCR自動(dòng)備份的內(nèi)容:
[root@rhel1 ~]# /oracle/app/crs/bin/ocrconfig -showbackup

rhel1     2010/10/26 05:20:57     /oracle/app/crs/cdata/crs

rhel1     2010/10/26 01:20:56     /oracle/app/crs/cdata/crs

rhel2     2010/10/24 22:34:18     /oracle/app/crs/cdata/crs

rhel1     2010/10/26 01:20:56     /oracle/app/crs/cdata/crs

rhel1     2010/10/22 23:54:15     /oracle/app/crs/cdata/crs

可以看到ocr備份在rhel1,rhel2都有分布。
切換到自動(dòng)備份目錄可以看到一共有7個(gè)備份,分別是每4小時(shí)的備份,保留最近的3個(gè)備份,當(dāng)天生成的OCR備份,保留最近2個(gè)備份。還有就是每周生成的備份,保留最近的2個(gè)。總共7個(gè)。
[root@rac1 ~]# ls -l /oracle/app/crs/cdata/crs
total 23560
-rw-r--r-- 1 root root 4812800 Oct 26 05:20 backup00.ocr
-rw-r--r-- 1 root root 4812800 Oct 26 01:20 backup01.ocr
-rw-r--r-- 1 root root 4812800 Oct 24 15:54 backup02.ocr
-rw-r--r-- 1 root root 4812800 Oct 27 02:10 day_.ocr
-rw-r--r-- 1 root root 4812800 Oct 26 01:20 day.ocr
-rw-r--r-- 1 root root 4812800 Oct 29 23:04 week_.ocr
-rw-r--r-- 1 root root 4812800 Oct 22 23:54 week.ocr

除了上面的自動(dòng)備份外,在執(zhí)行大的操作的時(shí)候還需要進(jìn)行手動(dòng)備份,通過(guò)OCRCONFIG命令來(lái)執(zhí)行邏輯手動(dòng)備份:
[root@rhel1 ~]# /oracle/app/crs/bin/ocrconfig -export ocr_logical_backup -s online
[root@rhel1 ~]# ls -l ocr_logical_backup
-rw-r--r-- 1 root root 103969 Nov  5 20:10 ocr_logical_backup

如果是在線邏輯備份OCR,加入 -s online參數(shù),確保OCR的一致性。
驗(yàn)證OCR的一致性使用:
/oracle/app/crs/bin/cluvfy comp ocr -n all

另外如果是使用ocfs2集群文件系統(tǒng),我們可以直接對(duì)ocr,vdisk磁盤文件進(jìn)行拷貝。如果是裸設(shè)備使用dd命令來(lái)備份ocr也是可以的。

恢復(fù):
1.還原自動(dòng)備份文件:
[root@rhel1 bin]# ./crsctl stop crs
Stopping resources. This could take several minutes.
Successfully stopped CRS resources.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

[root@rhel1 bin]# cat /etc/oracle/ocr.loc
#Device/file /u01/ocfs2fs/ocr2 being deleted
ocrconfig_loc=/u01/ocfs2fs/ocr
local_only=false

[root@rhel1 bin]# mv /u01/ocfs2fs/ocr /u01/ocfs2fs/ocr_bak
[root@rhel1 crs_1]# cd cdata
[root@rhel1 cdata]# cd crs
[root@rhel1 crs]# ll
total 23144
-rwxrwxr-x 1 oracle dba  3514368 Mar  1 11:00 13968559
-rwxrwxr-x 1 oracle dba  3514368 Mar  1 07:00 33426182
-rw-r--r-- 1 root   root 3182592 Mar  8 15:17 34809936
-rwxrwxr-x 1 oracle dba  3514368 Feb 27 09:38 backup00.ocr
-rwxrwxr-x 1 oracle dba  3514368 Feb  8 06:02 backup01.ocr
-rwxrwxr-x 1 oracle dba  2142208 Nov  8 19:25 backup02.ocr
-rwxrwxr-x 1 oracle dba  2142208 Nov  8 19:25 day.ocr
-rwxrwxr-x 1 oracle dba  2142208 Nov  8 19:25 week.ocr

[root@rhel1 crs]# cd ../../bin
[root@rhel1 bin]# ./ocrconfig -restore /u01/app/oracle/crs_1/cdata/crs/backup02.ocr
PROT-16: Internal Error
[root@rhel1 bin]#
touch /u01/ocfs2fs/ocr
[root@rhel1 bin]#
./ocrconfig -restore /u01/app/oracle/crs_1/cdata/crs/backup02.ocr
[root@rhel1 bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
[root@rhel1 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

2.恢復(fù)邏輯備份:
[root@rhel1 ~]# /oracle/app/crs/bin/ocrconfig -import logical_backup.ocr

在對(duì)Clusterware做大操作之前都應(yīng)該養(yǎng)成備份OCR和VOTEDISK的好習(xí)慣,并且物理備份和邏輯備份都要有。

注意:ocrconfig在使用-export和-import備份恢復(fù)的時(shí)候也需要停止crs的運(yùn)行,來(lái)完成。如果想在在線完成這個(gè)操作的話,需要在-export的時(shí)候指定:-export <filename> [-s online]。

其他:
./ocrconfig -showbackup     //查看自動(dòng)備份。
./ocrconfig -backuploc <dirname>     //改變自動(dòng)備份目錄。

//心跳超時(shí)時(shí)間
[oracle@rhel1 bin]$ ./crsctl get css misscount
60
//查看crs css evm對(duì)應(yīng)模塊
crsctl lsmodules css|crs|evm



新聞名稱:管理OCR與VoteDisk-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://bm7419.com/article26/dioicg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)品牌網(wǎng)站制作、標(biāo)簽優(yōu)化、微信小程序、網(wǎng)站內(nèi)鏈、品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開(kāi)發(fā)