管理oracle clusterware ( OCR )

管理oracle clusterware ( OCR )

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

If you already mirror the OCR, then you do not need to add an OCR location; Oracle automatically manages two OCRs when it mirrors the OCR. Oracle RAC environments do not support more than two OCRs, a primary OCR and a second OCR.

--ocrconfig語法
[root@rac1 ~]# 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.

自動備份 OCR
– 每 4 小時:CRS 會保留最後 3 個副本。  
– 每天結束時:CRS 會保留最後 2 個副本。  
– 每週結束時:CRS 會保留最後 2 個副本。
自動備份由Master Node CRSD進程完成,備份的默認位置是$CRS_HOME/crs/cdata/<cluster_name>目錄下,可以通過ocrconfig -backuploc <directory_name> 命令修改到新的目錄。

示例:

--顯示備份信息
[root@rac1 ~]# ocrconfig -showbackup

rac1     2012/02/20 20:45:32     /u01/crs1020/cdata/crs

rac1     2012/02/19 16:45:47     /u01/crs1020/cdata/crs

rac1     2012/02/18 22:18:40     /u01/crs1020/cdata/crs

rac1     2012/02/19 16:45:47     /u01/crs1020/cdata/crs

rac1     2012/02/19 16:45:47     /u01/crs1020/cdata/crs
[root@rac1 ~]# ll /u01/crs1020/cdata/crs/
total 28296
-rw-r--r-- 1 root root 4816896 Feb 20 20:45 backup00.ocr
-rw-r--r-- 1 root root 4816896 Feb 19 16:45 backup01.ocr
-rw-r--r-- 1 root root 4816896 Feb 18 22:18 backup02.ocr
-rw-r--r-- 1 root root 4816896 Feb 20 20:45 day_.ocr
-rw-r--r-- 1 root root 4816896 Feb 19 16:45 day.ocr
-rw-r--r-- 1 root root 4816896 Feb 19 16:45 week.ocr

--更改備份位置
[root@rac1 ~]# ocrconfig -backuploc /oracle/backup/ocr

使用物理備份恢復 OCR  
1. 找到物理備份:
   $ ocrconfig –showbackup  
2. 檢查其內容:
   # ocrdump  file_name –backupfile
3. 停止所有節點上的 Oracle Clusterware:  
   # crsctl stop crs  
4. 還原 OCR 物理備份:
   # ocrconfig –restore <CRS HOME>/cdata/jfv_clus/day.ocr   
5. 重新啓動所有節點上的 Oracle Clusterware:  
   # crsctl start crs  
6. 檢查 OCR 完整性:  
   $ cluvfy comp ocr -n all 
示例:

--找到物理備份: 
[root@rac1 ~]# ocrconfig -showbackup

--檢查其內容,dump不成功:   
[root@rac1 crs]# ocrdump  -backupfile day.ocr
PROT-302: Failed to initialize ocrdump

--停止所有節點上的 Oracle Clusterware:  
[root@rac2 ~]# crsctl stop crs
[root@rac1 ~]# crsctl stop crs
 
--還原 OCR 物理備份: 
[root@rac1 ~]# ocrconfig -restore /u01/crs1020/cdata/crs/backup00.ocr
--重新啓動所有節點上的 Oracle Clusterware:  
[root@rac2 ~]# crsctl start crs
[root@rac1 ~]# crsctl start crs

--檢查 OCR 完整性:  
RACDB1@rac1 /home/oracle$ cluvfy comp ocr -n all

手動備份 OCR  
每天都應將 OCR 自動備份備份到其他存儲設備:  
  – 使用首選備份工具。  
在進行重大更改之前和之後應對 OCR 進行邏輯備份
  # ocrconfig –export file name  
確保還原與當前系統配置相匹配的 OCR 備份。

使用邏輯備份恢復 OCR  
1. 找到使用 OCR 導出文件創建的邏輯備份。
 
2. 停止所有節點上的 Oracle Clusterware:  
   # crsctl stop crs  
3. 還原邏輯 OCR 備份:
   # ocrconfig –import /shared/export/ocrback.dmp  
4. 重新啓動所有節點上的 Oracle Clusterware:  
   # crsctl start crs
5. 檢查 OCR 完整性:  
   $ cluvfy comp ocr -n all 

修復 OCR 配置
添加,替換,刪除OCR配置或OCR配置更改時,如果某些節點停止了,需要在這些節點上修復OCR配置。
模擬修復過程:
1. 停止節點 2 上的 Oracle Clusterware:
  # crsctl stop crs   
2.  從節點 1 添加 OCR 鏡像:
  # ocrconfig –replace ocrmirror /dev/raw/raw8   
3.  修復節點 2 上的 OCR 鏡像位置:  
  # ocrconfig –repair ocrmirror /dev/raw/raw8
4.  啓動節點 2 上的 Oracle Clusterware:  
  # crsctl start crs 

更改 OCR 文件位置

示例:

--查看是否有OCR備份
[root@rac1 ~]# ocrconfig -showbackup

rac1     2012/02/19 16:45:47     /u01/crs1020/cdata/crs

rac1     2012/02/18 22:18:40     /u01/crs1020/cdata/crs

rac1     2012/02/12 19:52:33     /u01/crs1020/cdata/crs

rac1     2012/02/18 22:18:40     /u01/crs1020/cdata/crs

rac1     2012/02/19 16:45:47     /u01/crs1020/cdata/crs

--查看當前OCR配置
[root@rac1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4588
         Available space (kbytes) :      99756
         ID                       : 2037585895
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

--添加OCR鏡像,如果只有一個OCR文件,是不能直接改變這個OCR文件配置的,必須先添加鏡像後再修改。
[root@rac1 ~]# ocrconfig -replace ocrmirror /dev/raw/raw8

--確認添加成功
[root@rac1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4588
         Available space (kbytes) :      99756
         ID                       : 2037585895
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw8
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded


--更改Primary OCR位置,並進行確認
[root@rac1 ~]# ocrconfig -replace ocr /dev/raw/raw5  --我這裏raw5存儲太小了(PROT-22: Storage too small)
[root@rac1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4588
         Available space (kbytes) :      99756
         ID                       : 2037585895
         Device/File Name         : /dev/raw/raw5
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw8
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

OCR 注意事項  
如果使用裸設備還原 OCR 文件,則在執行添加或替換操作之前需要先確保這些文件已存在。  
使用 ocrconfig 時,必須具有 root 用戶身份才能添加、替換或刪除 OCR 文件。  
添加或替換 OCR 文件時,其鏡像需要處於聯機狀態。
如果刪除了 OCR 主文件,則 OCR 鏡像文件將成爲主文件。  
任何時候都不能刪除最後一個保留的 OCR 文件。  



參考:
大話 ORACLE RAC
Administering Oracle Clusterware Components
http://docs.oracle.com/cd/B19306_01/rac.102/b14197/votocr.htm#BABGEEEJ


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章