-
1:查看OCR自动备份
[grid@node2 node-cluster]$ ocrconfig -showbackup
node2 2015/07/23 08:08:18 /u01/app/11.2.0.4/grid/cdata/node-cluster/backup00.ocr
node2 2015/07/23 04:08:18 /u01/app/11.2.0.4/grid/cdata/node-cluster/backup01.ocr
node2 2015/07/23 00:08:16 /u01/app/11.2.0.4/grid/cdata/node-cluster/backup02.ocr
node2 2015/07/23 00:08:16 /u01/app/11.2.0.4/grid/cdata/node-cluster/day.ocr
node2 2015/07/23 00:08:16 /u01/app/11.2.0.4/grid/cdata/node-cluster/week.ocr
PROT-25: Manual backups for the Oracle Cluster Registry are not available 无需手动备份
-rw------- 1 root root 7204864 Jun 16 11:42 backup00.ocr
-rw------- 1 root root 7204864 Jun 16 07:42 backup01.ocr
-rw------- 1 root root 7204864 Jun 16 03:42 backup02.ocr
-rw------- 1 root root 7204864 Jun 16 07:42 day_.ocr
-rw------- 1 root root 7204864 Jun 15 07:42 day.ocr
-rw------- 1 root root 7204864 Jun 11 03:41 week_.ocr
-rw------- 1 root root 7204864 Jun 4 03:39 week.ocr
[grid@db1 db-cluster]$ pwd
/u01/app/11.2.0/grid/cdata/db-cluster
如果需要手动备份执行下面语句:
[root@node2 node-cluster]# ocrconfig -export /tmp/ocr_20150811.exp 可以在线备份 恢复命令:ocrconfig -import /tmp/ocr_20150811.ex
-
2:验证OCR
[grid@node2 node-cluster]$ cluvfy comp ocr -n all
-
3:查看OCR、VOTE和DG信息
(1)查看OCR信息
[grid@node1 grid]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 3108
Available space (kbytes) : 259012
ID : 1679364394
Device/File Name : +gridnewdg
Device/File integrity check failed
Device/File Name : +gridmirdg
Device/File integrity check failed
(2)查看VOTE
[grid@node1 grid]$ crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 2f845578e55a4f4bbf25d0864b0bc26b (/dev/mapper/crsB13) [GRIDNEWDG]
2. ONLINE 21c1c99ef5164faabf6186d04aeeb741 (/dev/mapper/crsC01) [GRIDNEWDG]
3. ONLINE 69eb761aef5c4f87bfaabf9a3e2db5e4 (/dev/mapper/crsB14) [GRIDNEWDG]
(3)查看DG信息
SQL> select name,path,mount_status,failgroup from v$asm_disk order by name;
NAME PATH MOUNT_STAT FAILGROUP
-------------------- ------------------------------ ---------- ------------------------------
DATADG_0000 /dev/mapper/dataB02 CACHED DATAFIAL08
DATADG_0001 /dev/mapper/dataB04 CACHED DATAFIAL08
DATADG_0002 /dev/mapper/dataB01 CACHED DATAFIAL04
DATADG_0003 /dev/mapper/dataB05 CACHED DATAFIAL09
DATADG_0005 /dev/mapper/dataB03 CACHED DATAFIAL04
GRIDMIRDG_0000 /dev/mapper/crsB11 CACHED GMIRFAIL01
GRIDMIRDG_0001 /dev/mapper/crsB12 CACHED GMIRFIAL02
GRIDNEWDG_0000 /dev/mapper/crsB13 CACHED GNEWFIAL04
GRIDNEWDG_0001 /dev/mapper/crsC01 CACHED GNEWFIAL05
GRIDNEWDG_0002 /dev/mapper/crsB14 CACHED GNEWFIAL03
根据上面可以看到:
OCR存放在gridnewdg中,同时存放一份镜像到gridmirdg
VOTE存放在gridnewdg中
数据库文件都存放在datadg中
-
4:备份ASM spfile信息
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +GRIDNEWDG/node-cluster/asmparame
terfile/registry.253.885742421
SQL> create pfile='/home/grid/asmpfile.ora' from spfile;
-
5:破坏性实验--清除gridnewdg和gridmirdg下所有磁盘中信息
(1)首先停止数据库:[oracle@node2 ~]$ srvctl stop database -d orcl 在一个节点执行即可
(2)停止节点2 集群:[root@node2 grid]# crsctl stop crs
(3)停止节点1集群:[root@node1 grid]# crsctl stop crs
(4)因为OCR和vote同时存在gridnewdg中,且ocr还做镜像到gridmirdg中
为了做vote和ocr恢复实验,需要清除gridnewdg中磁盘和gridmirdg中磁盘:
dd if=/dev/zero of=/dev/mapper/crsB13 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsB14 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsC01 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsB11 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsB12 bs=1M count=1000
这里因为磁盘crs*都有100G,只需要清除1G就行。因为ocr和vote文件大小在200M左右
-
6:验证破坏性试验
(1)启动其中一个节点 发下集群无法正常启动
尝试重新启动crs: [root@node1 user_root]# crsctl start crs 发现集群无法启动
(2)强制关闭非正常启动后的集群进程
停止启动失败的进群相关进程:[root@node1 cssd]# crsctl stop crs -f
-
7:以独占模式启动节点2
[root@node2 dbs]# crsctl start crs -excl -nocrs
-
8:创建CRSDG和CRSMIRDG磁盘组以及spfile
(1) 创建CRSDG和CRSMIRDG磁盘组
[grid@node2 ~]$ asmcmd 空的
ASMCMD> ls
ASMCMD>
ASMCMD> exit
[grid@node2 ~]$ su - oracle
Password:
[oracle@node2 ~]$ export ORACLE_SID=+ASM2
[oracle@node2 ~]$ export ORACLE_HOME=/u01/app/11.2.0.4/grid/
[oracle@node2 ~]$ export PATH=$PATH:$ORACLE_HOME/bin
[oracle@node2 ~]$ sqlplus sys as sysasm
SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 12 10:59:04 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
create diskgroup crsdg normal redundancy
failgroup crsfail01 DISK '/dev/mapper/crsB13'
failgroup crsfial02 DISK '/dev/mapper/crsB14'
failgroup crsfial03 DISK '/dev/mapper/crsC01'
attribute'compatible.asm' = '11.2.0.0.0';
create diskgroup crsmirdg normal redundancy
failgroup crsmirfail01 DISK '/dev/mapper/crsB11'
failgroup crsmirfial02 DISK '/dev/mapper/crsB12'
attribute'compatible.asm' = '11.2.0.0.0';
(2)编辑pfile文件
[grid@node2 ~]$ cat asmpfile.ora
+ASM1.asm_diskgroups='CRSDG','DATADG','CRSMIRDG'#Manual Mount
+ASM2.asm_diskgroups='CRSDG','DATADG','CRSMIRDG'#Manual Mount
*.asm_diskstring='/dev/mapper'
*.asm_power_limit=5
*.diagnostic_dest='/u01/app/grid'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='EXCLUSIVE'
(3)创建spfile文件
create spfile='+crsdg' from pfile='/home/grid/asmpfile.ora';
-
9:恢复OCR和VOTE
(1)编辑 /etc/oracle/ocr.loc 文件
[root@node2 grid]# cat /etc/oracle/ocr.loc
#Device/file getting replaced by device +gridmirdg
ocrconfig_loc=+crsdg
ocrmirrorconfig_loc=+crsmirdg
local_only=false
(2)恢复OCR
[root@node2 grid]# ocrconfig -restore /u01/app/11.2.0.4/grid/cdata/node-cluster/backup02.ocr
发现 crsdg和crsmirdg下都增加了ocrfile文件夹
[grid@node2 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2756
Available space (kbytes) : 259364
ID : 1679364394
Device/File Name : +crsdg
Device/File integrity check succeeded
Device/File Name : +crsmirdg
Device/File integrity check succeeded
(3)恢复VOTE
[grid@node2 ~]$ crsctl query css votedisk
Located 0 voting disk(s).
[grid@node2 ~]$ crsctl replace votedisk +crsdg 恢复失败
CRS-4602: Failed 27 to add voting file 7a69aa1a2f094feabf02db8c75fd966b.
CRS-4602: Failed 27 to add voting file 1bb71838797f4fb5bf25c6afcf53e5a0.
CRS-4602: Failed 27 to add voting file 849fb6ad7e134f3bbf72f9fce25d85ea.
Failed to replace voting disk group with +crsdg.
CRS-4000: Command Replace failed, or completed with errors.
-
10:重新恢复OCR和VOTE
(1)[root@node2 grid]# crsctl stop crs
(2)[root@node2 grid]# crsctl start crs -excl -nocrs
(3)重新清空磁盘
dd if=/dev/zero of=/dev/mapper/crsB13 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsB14 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsC01 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsB11 bs=1M count=1000
dd if=/dev/zero of=/dev/mapper/crsB12 bs=1M count=1000
(4)重新创建crsdg和crsmirdg
创建失败,扫描不到磁盘,原因是asm_disktring为空
(5)SQL> alter system set asm_diskstring = '/dev/mapper';
(6)创建spfile
create spfile='+crsdg' from pfile='/home/grid/asmpfile.ora';
或者
SQL> create pfile='/home/grid/pfile.txt' from memory;然后修改,再创建spfile。这是防止之前没有备份spfile文件
(7)重新恢复OCR
[root@node2 grid]# ocrconfig -restore /u01/app/11.2.0.4/grid/cdata/node-cluster/backup02.ocr
[root@node2 grid]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2756
Available space (kbytes) : 259364
ID : 1679364394
Device/File Name : +crsdg
Device/File integrity check succeeded
Device/File Name : +crsmirdg
(8)重新恢复VOTE
[root@node2 grid]# crsctl query css votedisk
Located 0 voting disk(s).
[root@node2 grid]# crsctl replace votedisk +crsdg
Successful addition of voting disk 2c6bf78bc9b04f0bbff6d96ced710f6e.
Successful addition of voting disk 0d14000c1d474f12bfdd0887922f8b9d.
Successful addition of voting disk 6da9877208eb4f9abf5d04584dc10968.
Successfully replaced voting disk group with +crsdg.
CRS-4266: Voting file(s) successfully replaced
[root@node2 grid]# crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 2c6bf78bc9b04f0bbff6d96ced710f6e (/dev/mapper/crsB13) [CRSDG]
2. ONLINE 0d14000c1d474f12bfdd0887922f8b9d (/dev/mapper/crsB14) [CRSDG]
3. ONLINE 6da9877208eb4f9abf5d04584dc10968 (/dev/mapper/crsC01) [CRSDG]
Located 3 voting disk(s).
-
11:重启两节点集群
(1)编辑节点1的/etc/oracle/ocr.loc
[root@node1 ~]# cat /etc/oracle/ocr.loc
#Device/file getting replaced by device +gridmirdg
ocrconfig_loc=+crsdg
ocrmirrorconfig_loc=+crsmirdg
local_only=false
(2)停掉节点2集群 ---因为之前节点2以独占方式启动
(3)启动两节点集群
-
12:重启之后问题解决
根据11步骤图片发现,集群正常启动,但是仍存在以下问题:
1:旧gridewdg存在OCR中
2:新的DG crsdg和crsmirdg不再OCR中
3:数据库orcl不再OCR中
问题1解决办法:
[grid@node2 ~]$ crsctl delete res ora.GRIDNEWDG.dg
问题2解决办法参考我的百度经验:OCR中添加ASM DG资源
问题3解决办法参考我的百度经验:PRCR-1001 : Resource ora.orcl.db does not e.