首页 > 代码库 > Oracle 12c RAC 替换 OCR 磁盘组操作步骤
Oracle 12c RAC 替换 OCR 磁盘组操作步骤
注:本文谢绝转载!
为方便以后的测试,整了一套新的测试环境,600G PCIe 闪存卡+8核CPU+16G内存。 把整个虚拟机从我的电脑上直接copy 过去,网络什么都没问题,但是RAC 的共享设备是重新添加的。 这样之前旧的数据都不存在。
所以用脚本直接重建了OCR和Voting Disk,RAC 启动,没有问题,但是磁盘组出现错乱,Dave 有强迫症的倾向,所以重新重新添加了一个磁盘组。 把OCR 和 voting disk 都替换到新创建的OCR 磁盘组了。
所以以下所有的操作,只为一个事情准备,就是在Oracle 12c RAC 环境下,更换OCR 磁盘组。从OCR_VOINT 改成 OCR。
实际上,更换OCR 和Voting 的操作和11g 一样,但是12c 会多出其他的部分,具体如下。
1 替换OCR 和 Voting disk
--替换VOTEDISK
[root@rac1 ~]# crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1.ONLINE f56b0e0be76b4f03bf4782230c783e67(/dev/asm-diskb) [OCR_VOTING]
Located 1 voting disk(s).
[root@rac1 ~]# crsctl replace votedisk +OCR
Successful addition of voting disk2aa04b8a77d84fcbbfd272ad2b665bcc.
Successful addition of voting disk7dd098bc01ec4fcebfc8f3e2f12f11b7.
Successful addition of voting diskd0b8ab3340ed4f6dbfa087f8f4a59c49.
Successful deletion of voting diskf56b0e0be76b4f03bf4782230c783e67.
Successfully replaced voting disk groupwith +OCR.
CRS-4266: Voting file(s) successfullyreplaced
[root@rac1 ~]# crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1.ONLINE 2aa04b8a77d84fcbbfd272ad2b665bcc(/dev/asm-diskf) [OCR]
2.ONLINE 7dd098bc01ec4fcebfc8f3e2f12f11b7(/dev/asm-diskg) [OCR]
3.ONLINE d0b8ab3340ed4f6dbfa087f8f4a59c49(/dev/asm-diskh) [OCR]
Located 3 voting disk(s).
[root@rac1 ~]#
[grid@rac1 rac1]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server Statedetails
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.DATA.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.OCR.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.OCR_VOTING.dg
OFFLINE OFFLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.net1.network
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.ons
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.proxy_advm
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE rac1 STABLE
ora.MGMTLSNR
1 ONLINE ONLINE rac1 169.254.193.105192.
168.57.5,STABLE
ora.asm
1 ONLINE ONLINE rac1 STABLE
2 ONLINE ONLINE rac2 STABLE
3 OFFLINE OFFLINE STABLE
ora.cndba.db
1 ONLINE OFFLINE STABLE
2 OFFLINE OFFLINE CorruptedControlfil
e,STABLE
ora.cvu
1 ONLINE ONLINE rac1 STABLE
ora.mgmtdb
1 ONLINE OFFLINE STABLE
ora.oc4j
1 ONLINE ONLINE rac1 STABLE
ora.rac1.vip
1 ONLINE ONLINE rac1 STABLE
ora.rac2.vip
1 ONLINE ONLINE rac2 STABLE
ora.scan1.vip
1 ONLINE ONLINE rac1 STABLE
--------------------------------------------------------------------------------
[grid@rac1 rac1]$
SQL> alter diskgroup ocr_voting dismount;
alter diskgroup ocr_voting dismount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15027: active use of diskgroup"OCR_VOTING" precludes its dismount
磁盘组正在被使用,使用md_backup 命令备份一下OCR,这里主要是查看这个磁盘组上有哪些文件,然后逐一转移走。
[grid@rac1 ~]$ asmcmd md_backup/tmp/ocr_back -G OCR_VOTING
Disk group metadata to be backed up:OCR_VOTING
Current alias directory path:rac-scan/ASMPARAMETERFILE
Current alias directory path: ASM
Current alias directory path:CNDBA/CONTROLFILE
Current alias directory path: ASM/PASSWORD
Current alias directory path: rac-scan
Current alias directory path: CNDBA
Current alias directory path:rac-scan/OCRFILE
2 更改控制文件位置
--查看当前控制文件位置
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA/CNDBA/CONTROLFILE/current.261.854948915
+OCR_VOTING/CNDBA/CONTROLFILE/current.268.854948917
--修改控制文件参数:
SQL> alter system set control_files =‘+DATA/CNDBA/CONTROLFILE/control01.ctl‘,‘+DATA/CNDBA/CONTROLFILE/control02.ctl‘,‘+DATA/CNDBA/CONTROLFILE/control03.ctl‘scope=spfile sid=‘*‘;
System altered.
这里注意,Oracle ASM 中的文件是由OMF 管理的,所以我们不能和之前查询的一样,执行稳定的ID,我们这里只能指定别名,然后OMF 会自动产生一个文件与别名对应,这里我们等会在验证。 继续下一步。
[grid@rac1 rac1]$ srvctl stop database -dcndba
[grid@rac1 rac1]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server Statedetails
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.DATA.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.OCR.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.OCR_VOTING.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
……
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE rac1 STABLE
ora.MGMTLSNR
1 ONLINE ONLINE rac1 169.254.193.105192.
168.57.5,STABLE
ora.asm
1 ONLINE ONLINE rac1 STABLE
2 ONLINE ONLINE rac2 STABLE
3 OFFLINE OFFLINE STABLE
ora.cndba.db
1 OFFLINE OFFLINE InstanceShutdown,ST
ABLE
2 OFFLINE OFFLINE InstanceShutdown,ST
ABLE
……
[grid@rac1 rac1]$
--移动控制文件位置
ASMCMD> pwd
+ocr_voting/cndba/controlfile
ASMCMD> ls
Current.268.854948917
ASMCMD> pwd
+ocr_voting/cndba/controlfile
ASMCMD> ls
Current.268.854948917
ASMCMD> cp Current.268.854948917 +DATA/CNDBA/CONTROLFILE/control01.ctl
copying+ocr_voting/cndba/controlfile/Current.268.854948917 ->+DATA/CNDBA/CONTROLFILE/control01.ctl
ASMCMD> cp Current.268.854948917+DATA/CNDBA/CONTROLFILE/control02.ctl
copying+ocr_voting/cndba/controlfile/Current.268.854948917 ->+DATA/CNDBA/CONTROLFILE/control02.ctl
ASMCMD> cp Current.268.854948917+DATA/CNDBA/CONTROLFILE/control03.ctl
copying+ocr_voting/cndba/controlfile/Current.268.854948917 ->+DATA/CNDBA/CONTROLFILE/control03.ctl
ASMCMD>
--启动数据库并查看:
[grid@rac1 rac1]$ srvctl start database -dcndba
[grid@rac1 rac1]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server Statedetails
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.DATA.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.OCR.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
ora.OCR_VOTING.dg
ONLINE ONLINE rac1 STABLE
ONLINE ONLINE rac2 STABLE
……
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE rac1 STABLE
ora.MGMTLSNR
1 ONLINE ONLINE rac1 169.254.193.105 192.
168.57.5,STABLE
ora.asm
1 ONLINE ONLINE rac1 STABLE
2 ONLINE ONLINE rac2 STABLE
3 OFFLINE OFFLINE STABLE
ora.cndba.db
1 ONLINE ONLINE rac1 Open,STABLE
2 ONLINE ONLINE rac2 Open,STABLE
……
--------------------------------------------------------------------------------
[grid@rac1 rac1]$
ASMCMD> pwd
+data/cndba/controlfile
ASMCMD> ls -l
Type Redund Striped Time Sys Name
CONTROLFILE UNPROT FINE DEC 08 11:00:00 Y Current.261.854948915
CONTROLFILE UNPROT FINE DEC 08 12:00:00 N control01.ctl => +DATA/ASM/CONTROLFILE/control01.ctl.276.865771415
CONTROLFILE UNPROT FINE DEC 08 12:00:00 N control02.ctl => +DATA/ASM/CONTROLFILE/control02.ctl.277.865771425
CONTROLFILE UNPROT FINE DEC 08 12:00:00 N control03.ctl => +DATA/ASM/CONTROLFILE/control03.ctl.278.865771431
ASMCMD>
--drop 还是报错,继续处理:
SQL> drop diskgroup ocr_voting includingcontents;
drop diskgroup ocr_voting includingcontents
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15027: active use of diskgroup"OCR_VOTING" precludes its dismount
3 更改ASM中密码文件位置
ASMCMD> showversion
ASM version : 12.1.0.1.0
ASMCMD> pwd
+ocr_voting
ASMCMD> ls -l
Type Redund Striped Time Sys Name
Y ASM/
Y CNDBA/
Y _MGMTDB/
PASSWORD UNPROT COARSE AUG 07 02:00:00 N orapwasm => +OCR_VOTING/ASM/PASSWORD/pwdasm.256.854938127
Y rac-scan/
ASMCMD>
我们这里直接在新的磁盘组里创建一个:
[grid@rac1 rac1]$ orapwdfile=‘+ocr/orapwasm‘ asm=y
Enter password for SYS:
[grid@rac1 rac1]$
--验证:
[grid@rac1 ~]$ srvctl config asm
ASM home: /u01/gridsoft/12.1.0
Password file: +OCR/orapwasm
ASM listener: LISTENER
ASM instance count: 3
Cluster ASM listener: ASMNET1LSNR_ASM
[grid@rac1 ~]$
4 修改online redo log 位置
进入asmcmd 看,还有onlineredo log 文件,继续转移。
SQL> select group#,thread#,blocksizefrom v$log;
GROUP# THREAD# BLOCKSIZE
---------- ---------- ----------
1 1 512
2 1 512
3 2 512
4 2 512
SQL> ALTER DATABASE ADD LOGFILE THREAD 1group 7 ‘+DATA‘ size 200M;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 1group 6 ‘+DATA‘ size 200M;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 1group 5 ‘+DATA‘ size 200M;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 2group 8 ‘+DATA‘ size 200M;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 2group 9 ‘+DATA‘ size 200M;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 2group 10 ‘+DATA‘ size 200M;
Database altered.
SQL> alter databasedrop logfile group 1;
Database altered.
SQL> alter database drop logfile group4;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter database drop logfile group3;
alter database drop logfile group 3
*
ERROR at line 1:
ORA-01624: log 3 needed for crash recoveryof instance cndba2 (thread 2)
ORA-00312: online log 3 thread 2:‘+DATA/CNDBA/ONLINELOG/group_3.269.854950325‘
ORA-00312: online log 3 thread 2:
‘+OCR_VOTING/CNDBA/ONLINELOG/group_3.271.854950331‘
--测试库,不等了,直接unarchive:
SQL> alter database clear unarchivedlogfile group 3;
Database altered.
SQL> alter database clear unarchivedlogfile group 2;
Database altered.
SQL> alter database drop logfile group2;
Database altered.
SQL> alter database drop logfile group3;
Database altered.
SQL> select group#,thread#,blocksize from v$log;
GROUP# THREAD# BLOCKSIZE
---------- ---------- ----------
5 1 512
6 1 512
7 1 512
8 2 512
9 2 512
10 2 512
6 rows selected.
5 修改asm spfile位置
--查看当前位置:
[grid@rac1 grid]$ gpnptool get -o-
……
<orcl:ASM-Profile id="asm"DiscoveryString="/dev/asm*"SPFile="+OCR_VOTING/rac-scan/ASMPARAMETERFILE/registry.253.854938125"Mode="remote"/>
……
Success.
[grid@rac1 grid]$
--修改:
[grid@rac1 /]$ sqlplus / as sysasm
SQL*Plus: Release 12.1.0.1.0 Production onTue Dec 9 12:37:03 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise EditionRelease 12.1.0.1.0 - 64bit Production
With the Real Application Clusters andAutomatic Storage Management options
SQL> create pfile=‘/tmp/pfile.asm‘ fromspfile;
File created.
SQL> create spfile=‘+OCR‘ FROMPFILE=‘/tmp/pfile.asm‘;
File created.
--检查:
[grid@rac1 grid]$ gpnptool get -o-
……
<orcl:ASM-Profile id="asm" DiscoveryString="/dev/asm*"SPFile="+OCR/rac-scan/ASMPARAMETERFILE/registry.253.865859837"Mode="remote"/>
……
Success.
[grid@rac1 grid]$
这里修改成功。
但是查看还是旧目录:
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ -----------------------------------------
spfile string +OCR_VOTING/rac-scan/ASMPARAME
TERFILE/registry.253.854938125
重启ASM实例,让修改生效:
SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started
Total System Global Area 1135747072 bytes
Fixed Size 2297344 bytes
Variable Size 1108283904 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ -----------------------------------------
spfile string +OCR/rac-scan/ASMPARAMETERFILE
/registry.253.865859837
SQL>
以上是在节点1操作的,在节点2 同样也需要重启ASM。
注意:在11g以后,重启ASM,整个节点的CRS 也就挂了。
[root@rac2 ~]# crs_stat -t
CRS-0184: Cannot communicate with the CRSdaemon.
所以改操作只能一个节点依次操作。
6 转移MGMTDB 数据文件
在Oracle 12c中,默认情况下,MGMTDB 实例的数据文件也是存放在OCR 磁盘组的,所以我们在drop 之前,必须先转移走对应的数据文件。 这里的具体操作,另篇blog 在说明。
7 drop 旧磁盘组
--在节点2 dismount 磁盘组:
SQL> alter diskgroup ocr_votingdismount;
Diskgroup altered.
--节点1 上drop:
SQL> drop diskgroup ocr_voting includingcontents;
Diskgroup dropped.
到此,更换成功,整个世界安静了。
--------------------------------------------------------------------------------------------
版权所有,文章禁止转载,否则追究法律责任!
AboutDave:
--------------------------------------------------------------------------------------------
QQ: 251097186
Email: tianlesoftware@gmail.com
Blog: http://blog.csdn.net/tianlesoftware
Weibo: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware
Dave 的QQ群:
--------------------------------------------------------------------------------------------
注意:加群必须注明表空间和数据文件关系 | 不要重复加群
CNDBA_1: 104207940 (满) CNDBA_2: 62697716 (满) CNDBA_3: 283816689
CNDBA_4: 391125754 CNDBA_5: 62697850 CNDBA_6: 62697977 CNDBA_7: 142216823(满)
Oracle 12c RAC 替换 OCR 磁盘组操作步骤