由于DMP平台创建Oracle RAC CRS磁盘组冗余模式为EXTERN,客户反馈需要调整为normal,因此生成此调整配置文档。
版 本 :Oracle 11.2.0.3.0 RAC
磁盘组:仲裁盘CRS;数据盘DATA;归档日志盘LOG
目标:将仲裁盘CRS磁盘组从EXTERN修改为normal
注意1: 更改OCR磁盘组冗余模式会需要重启ASM实例,因此建议在DMP平台部署完数据库后提前进行调整,避免后期生产上线后影响业务。
注意2:DMP平台需要先退出维护模式。
1. 现状查询
[grid@host-fefcfe206d88 ~]$ crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 6aa57a3b2fd64f2fbf16fe582ba78675 (/dev/asm-disk361b406dfc041710bc1f038f523103c7a) [CRS]
Located 1 voting disk(s).
[grid@host-fefcfe206d88 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2896
Available space (kbytes) : 259224
ID : 899896916
Device/File Name : +CRS
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 bypassed due to non-privileged user
[grid@host-fefcfe206d88 ~]$ asmcmd
ASMCMD> lsdg
State Type Rebal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 4096 4194304 30720 30272 0 30272 0 Y CRS/
MOUNTED EXTERN N 512 4096 1048576 204800 178647 0 178647 0 N DATA/
MOUNTED EXTERN N 512 4096 1048576 51200 51070 0 51070 0 N LOG/
sqlplus / as sysasm
set pagesize 300 linesize 300
col NAME for a10;
col COMPATIBILITY for a20;
col DATABASE_COMPATIBILITY for a20;
select GROUP_NUMBER,NAME,ALLOCATION_UNIT_SIZE,COMPATIBILITY,DATABASE_COMPATIBILITY from v$asm_diskgroup where NAME iN ('CRS');
GROUP_NUMBER NAME ALLOCATION_UNIT_SIZE COMPATIBILITY DATABASE_COMPATIBILI
------------ ---------- -------------------- -------------------- --------------------
1 CRS 4194304 11.2.0.0.0 10.1.0.0.0
col path for a60
select GROUP_NUMBER,DISK_NUMBER,TOTAL_MB/1024,NAME,PATH from v$asm_disk where GROUP_NUMBER='1';
GROUP_NUMBER DISK_NUMBER TOTAL_MB/1024 NAME PATH
------------ ----------- ------------- ---------- ------------------------------------------------------------
1 2 10 CRS_0002 /dev/asm-disk3622d0dc0304df4085d506d8d8dcc5548
1 1 10 CRS_0001 /dev/asm-disk369280531a04f6409afc021764243c17b
1 0 10 CRS_0000 /dev/asm-disk361b406dfc041710bc1f038f523103c7a
2. 备份操作
2.1 备份OCR(在其中1个节点上执行root用户)
mkdir -p /u01/app/grid/backup/
cd /u01/app/11.2/grid/bin/
./ocrconfig -export /u01/app/grid/backup/ocr.bak
或
./ocrconfig -manualbackup
[root@host-fefcfe206d88 bin]# ./ocrconfig -manualbackup
host-fefcfe50a326 2024/09/19 14:20:04 /u01/app/11.2/grid/cdata/mesprodHKVk/backup_20240919_142004.ocr
查看备份:
su - grid
$ ocrconfig -showbackup
$ ocrconfig -showbackup manual
2.2 备份VOTEDISK
联机文档说不需要备份votedisk,可以使用dd备份
##查看VOTEDISK位置
su - grid
crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 6aa57a3b2fd64f2fbf16fe582ba78675 (/dev/asm-disk361b406dfc041710bc1f038f523103c7a) [CRS]
Located 1 voting disk(s).
##备份votedisk盘:
su - root
dd if=/dev/asm-disk361b406dfc041710bc1f038f523103c7a of=/u01/voting_disk.bak
strings /u01/voting_disk.bak |sort -u
2.3 备份ASM参数文件
在OCR的磁盘组里,有OCR、VOTEDISK、ASM的SPFILE参数文件,但是这里ASM的参数文件是不需要备份的,因为我们一会在改ASM参数文件位置的时候,会生产PFILE文件,那时就已经是备份了。
2.4 恢复操作(如果真需要恢复的话)
##恢复votedisk盘:
dd if=/u01/voting_disk.bak of=/dev/asm-disk361b406dfc041710bc1f038f523103c7a
##恢复OCR:
#在所有RAC节点上停止CRS服务:
su - grid
crsctl stop crs -f
#在一个节点上以NOCRS方式启动CRS,此操作会启动ASM实例:
cd /u01/app/11.2.0/grid/bin/
./crsctl start crs -excl -nocrs
如果磁盘组已被破坏,需要新建磁盘组,如果磁盘组正常,可正常通过备份恢复:
create diskgroup CRS normal redundancy disk '/dev/asmocrA01','/dev/asmocrA02','/dev/asmocrA03' attribute 'compatible.asm' = '11.2','compatible.rdbms' = '10.1';
在/etc/oracle/ocr.loc中记录了OCR路径,修改ocrconfig_loc的值,以便将OCR恢复到新的磁盘组中:
[root@host-fefcfe206d88 bin]# cat /etc/oracle/ocr.loc
ocrconfig_loc=+CRS
local_only=FALSE
#查看OCR备份:
./ocrconfig -showbackup
#执行恢复操作:
./ocrconfig -restore /u01/app/grid/backup/ocr.bak
./ocrcheck
3. 执行迁移操作 迁移过程主要是把仲裁盘信息临时迁移到DATA磁盘组,然后重建CRS磁盘组,再迁移回CRS磁盘组
3.1 移到OCR到DATA磁盘组
备注:这里将OCR磁盘组移动到DATA这个磁盘组上,在一个节点操作即可。
当OCR只有一份时,如果移动则会报错:
[root@host-fefcfe206d88 bin]# ./ocrconfig -replace +CRS -replacement +DATA
PROT-28: Cannot delete or replace the only configured Oracle Cluster Registry location
#添加一份OCR
[root@host-fefcfe206d88 bin]# ./ocrconfig -add +DATA
#检查OCR位置
[root@host-fefcfe206d88 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2924
Available space (kbytes) : 259196
ID : 899896916
Device/File Name : +CRS
Device/File integrity check succeeded
Device/File Name : +DATA
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
#删除一份OCR
[root@host-fefcfe206d88 bin]# ./ocrconfig -delete +CRS
#检查OCR位置
[root@host-fefcfe206d88 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2924
Available space (kbytes) : 259196
ID : 899896916
Device/File Name : +DATA
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
#检查OCR位置
[root@host-fefcfe206d88 bin]# cat /etc/oracle/ocr.loc
#Device/file +CRS getting replaced by device +DATA
ocrconfig_loc=+DATA
3.2 移动VOTEDISK到DATA磁盘组
##移到VOTEDISK
[root@host-fefcfe206d88 bin]# ./crsctl replace votedisk +DATA
Successful addition of voting disk a6fcdc1353c74f43bfbd675e119bd737.
Successful deletion of voting disk 6aa57a3b2fd64f2fbf16fe582ba78675.
Successfully replaced voting disk group with +DATA.
CRS-4266: Voting file(s) successfully replaced
[root@host-fefcfe206d88 bin]# ./crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE a6fcdc1353c74f43bfbd675e119bd737 (/dev/asm-disk36376005c70423d0869d0f0b9f3111fc0) [DATA]
Located 1 voting disk(s).
备注:在一个节点操作即可。
##移动ASM参数文件
#查看ASM位置
su - grid
sqlplus / as sysasm
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +CRS/mesprodhkvk/asmparameterf
ile/registry.253.1180092925
#创建PFILE
SQL> create pfile='/home/grid/asminit.ora' from spfile='+CRS/mesprodhkvk/asmparameterfile/registry.253.1180092925';
#查看PFILE内容
$ cat /home/grid/asminit.ora
+ASM1.asm_diskgroups='DATA','LOG'#Manual Mount
+ASM2.asm_diskgroups='DATA','LOG'#Manual Mount
*.asm_diskstring='/dev/asm-disk*'
*.asm_power_limit=1
*.diagnostic_dest='/u01/app/grid'
*.instance_type='asm'
*.large_pool_size=12M
+ASM1.local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.18.143)(PORT=1521))))'
*.remote_login_passwordfile='EXCLUSIVE'
#关闭ASM实例
sqlplus / as sysasm
SQL> shutdown abort;
ASM instance shutdown
#以PFILE启动ASM实例
$sqlplus / as sysasm
SQL> startup pfile='/home/grid/asminit.ora';
ASM instance started
Total System Global Area 283930624 bytes
Fixed Size 2227664 bytes
Variable Size 256537136 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
#创建SPFILE
SQL> create spfile='+DATA' from pfile='/home/grid/asminit.ora';
#关闭ASM数据库并以SPFILE启动ASM实例
sqlplus / as sysasm
SQL> shutdown abort;
ASM instance shutdown
SQL> startup
ASM instance started
Total System Global Area 283930624 bytes
Fixed Size 2227664 bytes
Variable Size 256537136 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/mesprodhkvk/asmparameter
file/registry.253.1180105627
#节点二重启CLUSTER
将另一个节点的cluster重启以保证asm的spfile是新的参数文件
此时最好是将2个节点的cluster都重启下,让所有的资源都正常。
3.3 删除OCR磁盘组
##查看OCR磁盘组状态
节点一:
sqlplus / as sysasm
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
DATA MOUNTED
LOG MOUNTED
CRS MOUNTED
节点二:
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
DATA MOUNTED
LOG MOUNTED
CRS MOUNTED
##查看OCR磁盘组包括的磁盘
set pagesize 300 linesize 300
col name for a15
col path for a50
select name,GROUP_NUMBER ,DISK_NUMBER,state,REDUNDANCY ,TOTAL_MB,FREE_MB,path from v$asm_disk where name like 'CRS%';
NAME GROUP_NUMBER DISK_NUMBER STATE REDUNDA TOTAL_MB FREE_MB PATH
--------------- ------------ ----------- -------- ------- ---------- ---------- --------------------------------------------------
CRS_0002 3 2 NORMAL UNKNOWN 10240 10104 /dev/asm-disk3622d0dc0304df4085d506d8d8dcc5548
CRS_0001 3 1 NORMAL UNKNOWN 10240 10108 /dev/asm-disk369280531a04f6409afc021764243c17b
CRS_0000 3 0 NORMAL UNKNOWN 10240 10092 /dev/asm-disk361b406dfc041710bc1f038f523103c7a
##节点2卸载OCR磁盘
备注:节点一不卸载
SQL> alter diskgroup CRS dismount;
Diskgroup altered.
SQL> select name,state from v$asm_diskgroup;
NAME STATE
--------------- -----------
DATA MOUNTED
LOG MOUNTED
CRS DISMOUNTED
##OCR磁盘组删除
备注:在节点一操作
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
DATA MOUNTED
LOG MOUNTED
CRS MOUNTED
SQL> drop diskgroup CRS including contents;
Diskgroup dropped.
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
DATA MOUNTED
LOG MOUNTED
3.4 重建OCR磁盘组
sqlplus / as sysasm
##查看目录磁盘组兼容性,根据兼容性创建新磁盘组
SQL> set pagesize 300 linesize 300
SQL> select GROUP_NUMBER,NAME,COMPATIBILITY,DATABASE_COMPATIBILITY from v$asm_diskgroup;
GROUP_NUMBER NAME COMPATIBILITY DATABASE_COMPATIBILITY
------------ --------------- ---------------- --------------------------------
1 DATA 11.2.0.0.0 10.1.0.0.0
2 LOG 11.2.0.0.0 10.1.0.0.0
create diskgroup CRS normal redundancy disk '/dev/asm-disk3622d0dc0304df4085d506d8d8dcc5548','/dev/asm-disk369280531a04f6409afc021764243c17b','/dev/asm-disk361b406dfc041710bc1f038f523103c7a' attribute 'compatible.asm' = '11.2','compatible.rdbms' = '10.1';
SQL> select GROUP_NUMBER,NAME,COMPATIBILITY,DATABASE_COMPATIBILITY from v$asm_diskgroup;
GROUP_NUMBER NAME COMPATIBILITY DATABASE_COMPATIBILITY
------------ -------------- --------------------- -------------------------------
1 DATA 11.2.0.0.0 10.1.0.0.0
2 LOG 11.2.0.0.0 10.1.0.0.0
3 CRS 11.2.0.0.0 10.1.0.0.0
#节点一:
SQL> select name,state from v$asm_diskgroup;
NAME STATE
------------------------------ -----------
DATA MOUNTED
LOG MOUNTED
CRS MOUNTED
#节点二:
SQL> select name,state from v$asm_diskgroup;
NAME STATE
--------------- -----------
DATA MOUNTED
LOG MOUNTED
CRS DISMOUNTED
SQL> alter diskgroup CRS mount;
Diskgroup altered.
SQL> select name,state from v$asm_diskgroup;
NAME STATE
--------------- -----------
DATA MOUNTED
LOG MOUNTED
CRS MOUNTED
4. 将仲裁信息移回OCR磁盘组
4.1 OCR移回
#查看OCR位置
[root@host-fefcfe50a326 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2924
Available space (kbytes) : 259196
ID : 899896916
Device/File Name : +DATA
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
#添加一份OCR
[root@host-fefcfe50a326 bin]# ./ocrconfig -add +CRS
[root@host-fefcfe50a326 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2924
Available space (kbytes) : 259196
ID : 899896916
Device/File Name : +DATA
Device/File integrity check succeeded
Device/File Name : +CRS
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
#删除一份OCR
[root@host-fefcfe50a326 bin]# ./ocrconfig -delete +DATA
[root@host-fefcfe50a326 bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2924
Available space (kbytes) : 259196
ID : 899896916
Device/File Name : +CRS
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
4.2 VOTEDISK移回
#查看现有votedisk
[root@host-fefcfe50a326 bin]# ./crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE a6fcdc1353c74f43bfbd675e119bd737 (/dev/asm-disk36376005c70423d0869d0f0b9f3111fc0) [DATA]
Located 1 voting disk(s).
#替换votedisk
[root@host-fefcfe50a326 bin]# ./crsctl replace votedisk +CRS
Successful addition of voting disk 94696ded31274f1bbf87dafcda4b74a5.
Successful addition of voting disk 8a4c0668433f4f69bf45db63b86658f8.
Successful addition of voting disk 84796f250d6c4f76bf28f691c51e2b4d.
Successful deletion of voting disk a6fcdc1353c74f43bfbd675e119bd737.
Successfully replaced voting disk group with +CRS.
CRS-4266: Voting file(s) successfully replaced
#查看迁移后votedisk
[root@host-fefcfe50a326 bin]# ./crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 94696ded31274f1bbf87dafcda4b74a5 (/dev/asm-disk3622d0dc0304df4085d506d8d8dcc5548) [CRS]
2. ONLINE 8a4c0668433f4f69bf45db63b86658f8 (/dev/asm-disk369280531a04f6409afc021764243c17b) [CRS]
3. ONLINE 84796f250d6c4f76bf28f691c51e2b4d (/dev/asm-disk361b406dfc041710bc1f038f523103c7a) [CRS]
Located 3 voting disk(s).
5. ASM参数文件移回
#创建PFILE
$ sqlplus / as sysasm
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/mesprodhkvk/asmparameter
file/registry.253.1180105627
SQL> create pfile='/home/grid/asmocrinit.ora' from spfile='+DATA/mesprodhkvk/asmparameterfile/registry.253.1180105627';
File created.
#关闭ASM实例
$ sqlplus / as sysasm
SQL> shutdown abort;
ASM instance shutdown
#启动ASM实例
$ sqlplus / as sysasm
SQL> startup pfile='/home/grid/asmocrinit.ora';
ASM instance started
Total System Global Area 283930624 bytes
Fixed Size 2227664 bytes
Variable Size 256537136 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
#创建SPFILE
SQL> create spfile='+CRS' from pfile='/home/grid/asmocrinit.ora';
#关闭ASM实例
$ sqlplus / as sysasm
SQL> shutdown abort;
ASM instance shutdown
#节点一重新启动CLUSTER
[root@host-fefcfe50a326 bin]# ./crsctl stop cluster
[root@host-fefcfe50a326 bin]# ./crsctl start cluster
#节点二重新启动CLUSTER
[root@host-fefcfe50a326 bin]# ./crsctl stop cluster
[root@host-fefcfe50a326 bin]# ./crsctl start cluster
6. 查看OCR、VOTEDISK、ASM参数文件位置
##查看OCR位置
[grid@host-fefcfe206d88 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2924
Available space (kbytes) : 259196
ID : 899896916
Device/File Name : +CRS
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 bypassed due to non-privileged user
##查看VOTEDISK位置
[grid@host-fefcfe206d88 ~]$ crsctl query css votedisk
## STATE File Universal Id File Name Disk group
-- ----- ----------------- --------- ---------
1. ONLINE 94696ded31274f1bbf87dafcda4b74a5 (/dev/asm-disk3622d0dc0304df4085d506d8d8dcc5548) [CRS]
2. ONLINE 8a4c0668433f4f69bf45db63b86658f8 (/dev/asm-disk369280531a04f6409afc021764243c17b) [CRS]
3. ONLINE 84796f250d6c4f76bf28f691c51e2b4d (/dev/asm-disk361b406dfc041710bc1f038f523103c7a) [CRS]
Located 3 voting disk(s).
##查看ASM参数文件位置
$ sqlplus / as sysasm
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +CRS/mesprodhkvk/asmparameterf
ile/registry.253.1180111431
###至此,仲裁盘模式调整完成,调整过程需要重新启动群集服务,生产环境需要协调停机时间。
###最后,记得DMP重新进入维护模式。 |