背景:
用户有一套Oracle12.2的RAC集群,在安装配置的时候,OCR磁盘只使用了单块磁盘external的模式,想替换成包含三块磁盘组成员normal模式的磁盘组
OCR磁盘组存储的对象:
在替换OCR磁盘之前,我们先确认需要迁移的OCR磁盘组存储的对象
1 ocr集群的配置文件ocrfile,通过ocrcheck命令确认
2 ocr默认的备份路径(12c之后新的变化),通过ocrconfig -showbackup命令确认
3 ocr心跳盘,通过命令crsctl query css votedisk确认
4 asm实例的密码文件(12c之后新的变化),通过asmcmd pwget --asm命令确认
5 asm实例的spfile文件,通过命令
cat $ORACLE_HOME/gpnp/$hostname/profiles/peer/profile.xml |grep -i spfile |awk -F "SPFile" '{print $2}' |awk -F ">" '{print $1}'
OCR文件备份:
1 备份本地的集群配置文件OLR
$/u01/app/12.2.0.1/grid/bin/ocrconfig -local -manualbackup
2 备份OCR集群共享配置文件,如果备份的目录在ocr自己的diskgroup,要先修改到其他asm目录,异地存放
$/u01/app/12.2.0.1/grid/bin/ocrconfig -backuploc +DATA
$/u01/app/12.2.0.1/grid/bin/ocrconfig -manualbackup
3 备份asm pfile文件
SQL> create pfile='/tmp/initasm1.bak.20230419' from spfile;
4 备份asm 密码文件
ASMCMD>pwcopy +ocr/ASM/PASSWORD/pwdasm /tmp/asm.pwd.bak
OCR磁盘组替换:
查看当前OCR磁盘组的配置,当前的磁盘组名称为OCR,external模式
创建新的normal磁盘组OCRDG
--节点一执行,节点二mount
SQL> create diskgroup ocrdg normal redundancy disk
'/dev/mapper/ocrdg1','/dev/mapper/ocrdg2','/dev/mapper/ocrdg3'
attribute 'compatible.asm'='12.2.0.1.0','compatible.rdbms'='12.2.0.1.0';
添加OCRDG到ocrconfig
$/u01/app/12.2.0.1/grid/bin/ocrconfig -add +ocrdg
$/u01/app/12.2.0.1/grid/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 4
Total space (kbytes) : 901284
Used space (kbytes) : 96720
Available space (kbytes) : 804564
ID : 516241530
Device/File Name : +OCR
Device/File integrity check succeeded
Device/File Name : +OCRDG
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
在线替换ocr config集群配置文件磁盘组路径
--删除原有的路径ocr
$/u01/app/12.2.0.1/grid/bin/ocrconfig -delete +OCR
$/u01/app/12.2.0.1/grid/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 4
Total space (kbytes) : 901284
Used space (kbytes) : 96720
Available space (kbytes) : 804564
ID : 516241530
Device/File Name : +ocrdg
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
在线替换心跳投票盘
--替换投票盘为ocrdg
$/u01/app/12.2.0.1/grid/bin/crsctl replace votedisk +ocrdg
Successful addition of voting disk a6219f6847fb4f3abfc1c9e4618566e6.
Successful addition of voting disk ad3cf7c7e1b94fdfbff9dd920e7cb573.
Successful addition of voting disk 5defc32620594f34bfed90517e9225e2.
Successful deletion of voting disk 79e36291540d4f07bff30b9376e93ab8.
Successfully replaced voting disk group with +OCRDG.
CRS-4266: Voting file(s) successfully replaced
$/u01/app/12.2.0.1/grid/bin/crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE a6219f6847fb4f3abfc1c9e4618566e6 (/dev/mapper/ocrdg1) [OCRDG]
2. ONLINE ad3cf7c7e1b94fdfbff9dd920e7cb573 (/dev/mapper/ocrdg2) [OCRDG]
3. ONLINE 5defc32620594f34bfed90517e9225e2 (/dev/mapper/ocrdg3) [OCRDG]
迁移asm文件,需要停集群启动导独占模式
--迁移asm文件
SQL> show parameter pfile
--生成asm密码文件到本地路径
SQL> create pfile='/tmp/initasm1.20230419.ora' from spfile;
File created.
--启动到独占模式,迁移asm pfile文件
$/u01/app/12.2.0.1/grid/bin/crsctl stop crs
$/u01/app/12.2.0.1/grid/bin/crsctl start crs -excl -nocrs
--将asm密码文件生成到新的OCRDG里面
--新的ASM spfile路径会自动更新到gnpnp profile里面
SQL> create spfile='+OCRDG' from pfile='/tmp/initasm1.20230419.ora';
--重启集群
$/u01/app/12.2.0.1/grid/bin/crsctl stop crs
$/u01/app/12.2.0.1/grid/bin/crsctl start crs
迁移asm 密码文件
--查看当前asm的路径
ASMCMD> pwget --asm
+OCR/ASM/PASSWORD/pwdasm
ASMCMD> ls +OCR/ASM/PASSWORD/pwdasm
pwdasm.256.844043619
--通过pwcopy方式迁移到新的磁盘OCRDG路径下
ASMCMD> pwcopy --asm +OCR/ASM/PASSWORD/pwdasm +OCRDG/ASM/PASSWORD/pwdasm
--如果提示ASMCMD-8028,则需要添加force
ASMCMD-8028: Password file '+OCR/ASM/PASSWORD/pwdasm' is associated with 'asm' already. Use the force option.
ASMCMD> pwcopy --asm +OCR/ASM/PASSWORD/pwdasm +ocrdg/ASM/PASSWORD/pwdasm -f
ASMCMD> pwget --asm
+ocrdg/ASM/PASSWORD/pwdasm
修改OCR备份路径
--这里建议ocr备份异地存放,不用放在通ocr相同的磁盘组里面
/u01/app/12.2.0.1/grid/bin/ocrconfig -backuploc +DATA
至此,ocr磁盘组替换完成,建议重启一下集群,验证有没有问题
/u01/app/12.2.0.1/grid/bin/crsctl stop crs
/u01/app/12.2.0.1/grid/bin/crsctl start crs