OCR磁盤的導出和導入、備份和恢復以及移動(ocrconfig命令的應用)


數據庫版本:10.2.0.1

一,使用導出、導入進行備份和恢復

Oracle推薦在對集群做調整時,比如增加、刪除節點之前,應該對OCR做一個備份,可以使用export 備份到指定文件。如果做了replace或restore等操作,Oracle建議使用"cluvfy comp ocr -n all" 命令做一次全面檢查。

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

[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    ONLINE    ONLINE    rac3        
ora....b1.inst application    ONLINE    ONLINE    rac3        
ora....b2.inst application    ONLINE    ONLINE    rac4        
ora....rver.cs application    ONLINE    ONLINE    rac3        
ora....db2.srv application    ONLINE    ONLINE    rac3  


[root@rac3 bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[oracle@rac4 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    ONLINE    ONLINE    rac3        
ora....b1.inst application    ONLINE    ONLINE    rac3        
ora....b2.inst application    ONLINE    ONLINE    rac4        
ora....rver.cs application    ONLINE    ONLINE    rac3        
ora....db2.srv application    ONLINE    ONLINE    rac3        


[root@rac4 bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

 


2.導出OCR內容(需要root用戶導出)

[root@rac4 bin]# ./ocrconfig -export /home/oracle/ocr.exp
[root@rac4 bin]# ll /home/oracle/ocr.exp 
-rw-r--r--  1 root root 98847 Jan 27 11:23 /home/oracle/ocr.exp

 

3.重新啟動CRS

[root@rac3 bin]# ./crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly


[root@rac4 bin]# ./crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly

 

4.檢查CRS狀態

[root@rac3 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

[root@rac4 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

 

5.破壞ocr內容

[root@rac4 bin]# dd if=/dev/zero of=/dev/raw/raw1 bs=1M count=120
dd: writing `/dev/raw/raw1': No space left on device
102+0 records in
101+0 records out

 

6.現在檢查ocr一致性

[root@rac4 bin]# ./ocrcheck
PROT-601: Failed to initialize ocrcheck

[root@rac3 bin]# ./ocrcheck
PROT-601: Failed to initialize ocrcheck

 

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

[root@rac3 cluvfy]# pwd
/opt/clusterware/cluvfy
[root@rac3 cluvfy]# ./runcluvfy.sh  comp ocr -n all

Verifying OCR integrity 
Unable to retrieve nodelist from Oracle clusterware.

Verification cannot proceed.

同樣是檢查失敗

 

8.現在查看集群狀態

[oracle@rac3 ~]$ crs_stat -t    --ocr被破壞,集群已經宕掉
CRS-0184: Cannot communicate with the CRS daemon.

[oracle@rac4 ~]$ crs_stat -t
CRS-0184: Cannot communicate with the CRS daemon.

 

9.使用import恢復OCR內容

[root@rac4 bin]# ./ocrconfig -import /home/oracle/ocr.exp 
[root@rac4 bin]#

 

10.再次檢查OCR

[root@rac4 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded
[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

 

11.檢查通過,用cluvfy工具檢查

[oracle@rac3 cluvfy]$ ./runcluvfy.sh  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. 

 

12.啟動CRS

[root@rac3 bin]# ./crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly


[root@rac4 bin]# ./crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly
[oracle@rac4 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    OFFLINE               
ora....C3.lsnr application    ONLINE    OFFLINE               
ora.rac3.gsd   application    ONLINE    OFFLINE               
ora.rac3.ons   application    ONLINE    OFFLINE               
ora.rac3.vip   application    ONLINE    OFFLINE               
ora....SM2.asm application    ONLINE    OFFLINE               
ora....C4.lsnr application    ONLINE    OFFLINE               
ora.rac4.gsd   application    ONLINE    OFFLINE               
ora.rac4.ons   application    ONLINE    OFFLINE               
ora.rac4.vip   application    ONLINE    OFFLINE               
ora.racdb.db   application    ONLINE    OFFLINE               
ora....b1.inst application    ONLINE    OFFLINE               
ora....b2.inst application    ONLINE    OFFLINE               
ora....rver.cs application    ONLINE    OFFLINE               
ora....db2.srv application    ONLINE    OFFLINE 

 

13.最后檢查CRS的狀態

[root@rac3 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

[root@rac4 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

 

二,移動OCR文件的位置

以下示例將演示如何把OCR從/dev/raw/raw1移動到/dev/raw/raw8上

1.首先查看是否有最近的OCR備份

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

rac4     2015/01/23 17:54:53     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac3     2014/10/10 16:51:14     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac3     2014/10/10 12:51:11     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac4     2015/01/23 17:54:53     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac4     2015/01/23 17:54:53     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

 

更改備份位置 ocrconfig -backuploc /oracle/backup/ocr

如果沒有備份,可以立即執行一次導出作為備份

[root@rac3 bin]# ./ocrconfig -export /home/oracle/ocr.bak2 -s online

[root@rac3 bin]#

 

 

2.查看當前ocr配置

[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

輸出顯示當前只有一個Primary OCR,位於 /dev/raw/raw1,沒有Mirror OCR

 

 

3.因為現在只有一個OCR文件,位於/dev/raw/raw1,所以不能直接改變這個OCR的位置,
必須先添加鏡像后再修改,否則會出現錯誤:

[root@rac3 bin]# ./ocrconfig -replace ocr /dev/raw/raw8
PROT-16: Internal Error

 

4.添加一個Mirror OCR

[root@rac3 bin]# ./ocrconfig -replace ocrmirror /dev/raw/raw7
[root@rac3 bin]# 

 

5.確認添加成功

[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7    --新添加的Mirror OCR
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

現在有兩個OCR了,可以修改原來的Primary OCR了

 

6.修改Primary OCR為/dev/raw/raw8

 

[root@rac3 bin]# ./ocrconfig -replace ocr /dev/raw/raw8
[root@rac3 bin]# 

 

7.確認修改成功

[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    2096364
         Used space (kbytes)      :       4340
         Available space (kbytes) :    2092024
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw8   --Primary OCR改變了
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

 

8.確認修改被同步到了其他節點

--在另一節點也能看到更新的信息

[root@rac4 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    2096364
         Used space (kbytes)      :       4340
         Available space (kbytes) :    2092024
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw8
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

 

9.使用ocrconfig -replace命令后,所有節點上的/etc/oracle/ocr.loc文件內容也都自動同步了,
如果有點節點沒有同步,也可以手工修改使其同步:

[root@rac4 bin]# more /etc/oracle/ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw8
ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false

 

 

三,解決PROT-22: Storage too small錯誤

現在我想改回原來的Primary OCR

[root@rac3 bin]# ./ocrconfig -replace ocr /dev/raw/raw1
PROT-22: Storage too small

查詢metalink發現,這是一個10.2.0.1上的bug,要求ocrmirror設備的大小要比原始ocr設備大128M,詳細描述可以參考:ID 317628.1。

 

那如何更改過來????  可參考 http://blog.itpub.net/14284241/viewspace-442842/
嘗試直接修改/etc/oracle/orc.loc文件

1.查看目前的OCR配置

[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    2096364
         Used space (kbytes)      :       4340
         Available space (kbytes) :    2092024
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw8
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

 

2.對目前的OCR備份

[root@rac3 bin]# ./ocrconfig -export /home/oracle/ocr.bak3 -s online
[root@rac3 bin]# 

 

3.停掉所有節點的CRS

[root@rac3 bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources 
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.


[root@rac4 bin]# ./crsctl stop crs
Stopping resources.
Error while stopping resources. Possible cause: CRSD is down.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

 

4.手動修改所有節點的/etc/oracle/ocr.loc文件

[root@rac3 bin]# more /etc/oracle/ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw8
ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false
[root@rac3 bin]# vi /etc/oracle/ocr.loc
[root@rac3 bin]# more /etc/oracle/ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw1
#ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false


[root@rac4 bin]# more /etc/oracle/ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw8
ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false
[root@rac4 bin]# vi /etc/oracle/ocr.loc
[root@rac4 bin]# more /etc/oracle/ocr.loc 
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8 
ocrconfig_loc=/dev/raw/raw1
#ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false

 

5.檢查一下ocr  

--可以看到ocr現在檢查報錯

[root@rac3 bin]# ./ocrcheck
PROT-601: Failed to initialize ocrcheck

 

6.導入之前備份的OCR數據

[root@rac3 bin]# ./ocrconfig -import /home/oracle/ocr.bak3

 

7.現在檢查ocr 

--兩個節點檢查正常,且ocr盤實現已經改過來了

[root@rac3 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       : 1887132889
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded



[root@rac4 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       : 1887132889
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

 

8.啟動crs

[root@rac3 bin]# ./crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly


[root@rac4 bin]# ./crsctl start crs
Attempting to start CRS stack 
The CRS stack will be started shortly
[oracle@rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3        
ora....C3.lsnr application    ONLINE    ONLINE    rac3        
ora.rac3.gsd   application    ONLINE    ONLINE    rac3        
ora.rac3.ons   application    ONLINE    ONLINE    rac3        
ora.rac3.vip   application    ONLINE    ONLINE    rac3        
ora....SM2.asm application    ONLINE    ONLINE    rac4        
ora....C4.lsnr application    ONLINE    ONLINE    rac4        
ora.rac4.gsd   application    ONLINE    ONLINE    rac4        
ora.rac4.ons   application    ONLINE    ONLINE    rac4        
ora.rac4.vip   application    ONLINE    ONLINE    rac4        
ora.racdb.db   application    ONLINE    ONLINE    rac4        
ora....b1.inst application    ONLINE    ONLINE    rac3        
ora....b2.inst application    ONLINE    ONLINE    rac4        
ora....rver.cs application    ONLINE    ONLINE    rac3        
ora....db2.srv application    ONLINE    ONLINE    rac4

 

9.檢查crs狀態

[root@rac3 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy


[root@rac4 bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

至此我么把ocr盤通過手動的方式更改過來了,RAC正常。

 

--本文章 部分參考張曉明<<大話Oracle RAC>>及其他

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM