OCR的备份与恢复

发布于:2025-04-05 ⋅ 阅读:(32) ⋅ 点赞:(0)

1.简介

在Oracle RAC环境中,ASM(Automatic Storage Management)管理的OCR(Oracle Cluster Registry)是集群的关键组件,存储集群配置和状态信息。

OCR的备份一般指物理备份,系统默认每4个小时自动备份一次,保留最近8次的备份,当然也可以手动执行一次备份。默认路径为$GRID_HOME/cdata下

2.使用方法

查看备份(root用户执行)

 ocrconfig -showbackup

rac1     2025/03/18 08:50:50     /opt/app/11.2.0/grid/cdata/rac-cluster/backup00.ocr

rac1     2025/03/18 04:50:50     /opt/app/11.2.0/grid/cdata/rac-cluster/backup01.ocr

rac1     2024/12/25 01:00:32     /opt/app/11.2.0/grid/cdata/rac-cluster/backup02.ocr

rac1     2025/03/18 04:50:50     /opt/app/11.2.0/grid/cdata/rac-cluster/day.ocr

rac1     2025/03/18 04:50:50     /opt/app/11.2.0/grid/cdata/rac-cluster/week.ocr

rac1     2025/04/04 06:23:32     /opt/app/11.2.0/grid/cdata/rac-cluster/backup_20250404_062332.ocr

手动触发备份

[root@rac1 ~]# ocrconfig  -manualbackup

rac1     2025/04/04 06:36:02     /opt/app/11.2.0/grid/cdata/rac-cluster/backup_20250404_063602.ocr

rac1     2025/04/04 06:23:32     /opt/app/11.2.0/grid/cdata/rac-cluster/backup_20250404_062332.ocr

恢复

ocrconfig -restore file_name

DUMP查看OCR信息

ocrdump -backupfile /opt/app/11.2.0/grid/cdata/rac-cluster/backup_20250404_063602.ocr

3.模拟故障

删除OCR信息

ASMCMD> cd +OCR/rac*
ASMCMD> ls
ASMPARAMETERFILE/
OCRFILE/
ASMCMD> cd OCRFILE
ASMCMD> ls
[root@rac1 cdata]# ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3176
         Available space (kbytes) :     258944
         ID                       :  161991732
         Device/File Name         :       +OCR
                                    Device/File integrity check succeeded

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

                                    Device/File not configured

         Cluster registry integrity check succeeded

         Logical corruption check succeeded
#尝试ASM删除
ASMCMD> rm -f REGISTRY.255.1197524291
ORA-15032: not all alterations performed
ORA-15028: ASM file '+OCR/rac-cluster/OCRFILE/REGISTRY.255.1197524291' not dropped; currently being accessed (DBD ERROR: OCIStmtExecute)
#无法删除,直接DD
dd if=/dev/zero of=/dev/sdb bs=1024 count=61440
61440+0 records in
61440+0 records out
62914560 bytes (63 MB) copied, 2.21147 s, 28.4 MB/s

重启集群

[root@rac1 ~]# crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4530: Communications failure contacting Cluster Synchronization Services daemon
CRS-4534: Cannot communicate with Event Manager
#CSS进程无法启动,查看CSS日志/opt/app/11.2.0/grid/log/rac1/cssd/cssd.log

2025-04-04 07:06:42.679: [   SKGFD][855086848]Lib :UFS:: closing handle 0x7f9b1c1592e0 for disk :/dev/asm-ocr:

2025-04-04 07:06:42.679: [   SKGFD][855086848]Lib :UFS:: closing handle 0x7f9b1c140580 for disk :/dev/asm-redo:

2025-04-04 07:06:42.679: [   SKGFD][855086848]Lib :UFS:: closing handle 0x7f9b1c159b80 for disk :/dev/asm-data:

2025-04-04 07:06:42.679: [   SKGFD][855086848]Lib :UFS:: closing handle 0x7f9b1c13ee10 for disk :/dev/asm-arc:

2025-04-04 07:06:42.679: [    CSSD][855086848]clssnmvDiskVerify: Successful discovery of 0 disks
2025-04-04 07:06:42.679: [    CSSD][855086848]clssnmCompleteInitVFDiscovery: Completing initial voting file discovery
2025-04-04 07:06:42.679: [    CSSD][855086848]clssnmvFindInitialConfigs: No voting files found
2025-04-04 07:06:42.679: [    CSSD][855086848](:CSSNM00070:)clssnmCompleteInitVFDiscovery: Voting file not found. Retrying discovery in 15 seconds

#找不到仲裁盘

4.恢复步骤

完全关闭集群

crsctl stop crs -f
#如无法关闭,杀掉css和ohas相关进程

nocrs启动集群

[root@rac1 ~]# crsctl start crs -excl -nocrs
CRS-4123: Oracle High Availability Services has been started.
CRS-2673: Attempting to stop 'ora.mdnsd' on 'rac1'
CRS-2673: Attempting to stop 'ora.gipcd' on 'rac1'
CRS-2673: Attempting to stop 'ora.crf' on 'rac1'
CRS-2677: Stop of 'ora.mdnsd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.gipcd' on 'rac1' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'rac1'
CRS-2677: Stop of 'ora.crf' on 'rac1' succeeded
CRS-2677: Stop of 'ora.gpnpd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.mdnsd' on 'rac1'
CRS-2676: Start of 'ora.mdnsd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.gpnpd' on 'rac1'
CRS-2676: Start of 'ora.gpnpd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac1'
CRS-2672: Attempting to start 'ora.gipcd' on 'rac1'
CRS-2676: Start of 'ora.cssdmonitor' on 'rac1' succeeded
CRS-2676: Start of 'ora.gipcd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cssd' on 'rac1'
CRS-2672: Attempting to start 'ora.diskmon' on 'rac1'
CRS-2676: Start of 'ora.diskmon' on 'rac1' succeeded
CRS-2676: Start of 'ora.cssd' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.drivers.acfs' on 'rac1'
CRS-2679: Attempting to clean 'ora.cluster_interconnect.haip' on 'rac1'
CRS-2672: Attempting to start 'ora.ctssd' on 'rac1'
CRS-2681: Clean of 'ora.cluster_interconnect.haip' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.cluster_interconnect.haip' on 'rac1'
CRS-2676: Start of 'ora.drivers.acfs' on 'rac1' succeeded
CRS-2676: Start of 'ora.ctssd' on 'rac1' succeeded
CRS-2676: Start of 'ora.cluster_interconnect.haip' on 'rac1' succeeded
CRS-2679: Attempting to clean 'ora.asm' on 'rac1'
CRS-2681: Clean of 'ora.asm' on 'rac1' succeeded
CRS-2672: Attempting to start 'ora.asm' on 'rac1'
CRS-2676: Start of 'ora.asm' on 'rac1' succeeded

修改搜索磁盘路径参数


SQL> show parameter string;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskstring                       string
SQL> alter system set asm_diskstring='/dev/asm*' scope=memory sid='*';

System altered.

重建OCR磁盘组

create diskgroup OCR external redundancy disk
'/dev/asm-ocr' attribute 'au_size'='1M','compatible.asm'='11.2','compatible.rdbms'='10.1';

还原OCR备份

ocrconfig -restore /opt/app/11.2.0/grid/cdata/rac-cluster/backup_20250404_063602.ocr

重建仲裁盘

[root@rac1 ~]# crsctl replace votedisk +OCR
Successful addition of voting disk 077b44c983b74ff0bfb6c84b20e1c93a.
Successfully replaced voting disk group with +OCR.
CRS-4266: Voting file(s) successfully replaced
[root@rac1 ~]# crsctl query css votedisk
##  STATE    File Universal Id                File Name Disk group
--  -----    -----------------                --------- ---------
 1. ONLINE   077b44c983b74ff0bfb6c84b20e1c93a (/dev/asm-ocr) [OCR]
Located 1 voting disk(s).

重建ASM实例参数文件

#如果之前备份生成过pfile,用pfile创建,没有的话查看alert日志自己手动创建一个pfile.ora
SQL> create spfile='+OCR' from pfile='/home/grid/pfile.ora';

File created.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
[grid@rac1 ~]$ asmcmd spget
+OCR/rac-cluster/asmparameterfile/registry.253.1197531403

重启集群

crsctl stop crs -f
crsctl start crs

另一个节点也启动

验证集群状态

[root@rac1 ~]# crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

**

注意:因为无法模拟OCR文件损坏,所以,直接破坏的OCR磁盘,真正生产环境中遇到OCR文件损坏,只要执行ocr的转储即可,不需要重建仲裁盘和SPFILE;如果业务正常,也不需要重启集群

**


网站公告

今日签到

点亮在社区的每一天
去签到