12c下更换ASM磁盘

12c以前的更换磁盘步骤见:http://blog.itpub.net/22621861/viewspace-1320369/

12c开始,更换ASM磁盘更加便捷。

首先确认当前ASM磁盘和磁盘组的对应情况。

点击(此处)折叠或打开

  1. $ sqlplus / as sysasm

  2. col disk_name format a20
  3. col diskgroup_name format a40
  4. select a.name as disk_name, b.name as diskgroup_name from v$asm_disk a, v$asm_diskgroup b
  5. where a.group_number = b.group_number;

DISK_NAME            DISKGROUP_NAME
-------------------- ----------------------------------------
DATA1                DATA
DATA2                DATA
DATA3                DATA
FRA1                 FRA
FRA2                 FRA
FRA3                 FRA
OCR1                 OCRV
OCR2                 OCRV
OCR3                 OCRV
VD1                  OCRV
VD2                  OCRV
VD3                  OCRV

计划更换磁盘OCR1,确认当前该ASM磁盘对应设备

点击(此处)折叠或打开

  1. # oracleasm querydisk /dev/sdc1
  2. Device "/dev/sdc1" is marked an ASM disk with the label "OCR1"
处于Online状态的磁盘不能replace,否则会发生报错:

点击(此处)折叠或打开

  1. SQL> alter diskgroup OCRV replace disk OCR1 with '/dev/sdo1' power 4;
  2. alter diskgroup OCRV replace disk OCR1 with '/dev/sdo1' power 4
  3. *
  4. ERROR at line 1:
  5. ORA-15032: not all alterations performed
  6. ORA-15145: ASM disk 'OCR1' is online and cannot be replaced.
尝试将OCR1磁盘offline,产生报错:

点击(此处)折叠或打开

  1. SQL> ALTER DISKGROUP OCRV OFFLINE DISK OCR1;
  2. ALTER DISKGROUP OCRV OFFLINE DISK OCR1
  3. *
  4. ERROR at line 1:
  5. ORA-15032: not all alterations performed
  6. ORA-15283: ASM operation requires compatible.rdbms of 11.1.0.0.0 or higher
根据MOS ID 1571975.1
需要设置参数。

先查看当前参数:

点击(此处)折叠或打开

  1. SQL> select NAME ,COMPATIBILITY,DATABASE_COMPATIBILITY from v$asm_diskgroup where name='OCRV';

  2. NAME
  3. ------------------------------------------------------------
  4. COMPATIBILITY
  5. --------------------------------------------------------------------------------
  6. DATABASE_COMPATIBILITY
  7. --------------------------------------------------------------------------------
  8. OCRV
  9. 12.1.0.0.0
  10. 10.1.0.0.0
设置参数:

点击(此处)折叠或打开

  1. SQL> ALTER DISKGROUP OCRV SET ATTRIBUTE 'COMPATIBLE.RDBMS'='12.1.0.0.0';

  2. Diskgroup altered.

  3. SQL> select NAME ,COMPATIBILITY,DATABASE_COMPATIBILITY from v$asm_diskgroup where name='OCRV';

  4. NAME
  5. ------------------------------------------------------------
  6. COMPATIBILITY
  7. --------------------------------------------------------------------------------
  8. DATABASE_COMPATIBILITY
  9. --------------------------------------------------------------------------------
  10. OCRV
  11. 12.1.0.0.0
  12. 12.1.0.0.0

此时,可以将磁盘offline

点击(此处)折叠或打开

  1. SQL> ALTER DISKGROUP OCRV OFFLINE DISK OCR1;

  2. Diskgroup altered.
要添加的磁盘需要符合以下条件:
1)RAC中其他节点也可访问;
2)设备所有者和权限符合要求,可用裸设备方式(详见http://blog.itpub.net/22621861/viewspace-2116865/);
3)设备名符合参数asm_diskstring。

点击(此处)折叠或打开

  1. SQL> alter system set asm_diskstring='ORCL:*','/dev/raw/raw*' sid='*' scope=both;

  2. System altered.

  3. SQL> show parameter asm_diskstring

  4. NAME TYPE
  5. ------------------------------------ ----------------------
  6. VALUE
  7. ------------------------------
  8. asm_diskstring string
  9. ORCL:*, /dev/raw/raw*
接下来,可以replace了


点击(此处)折叠或打开

  1. alter diskgroup OCRV replace disk OCR1 with '/dev/raw/raw1' power 4;

  2. Diskgroup altered.
确认

点击(此处)折叠或打开

  1. col name format a10
  2. col path format a20
  3. select name,path,total_mb from v$asm_disk;

  4. NAME PATH TOTAL_MB
  5. ---------- -------------------- ----------

  6. OCR1 /dev/raw/raw1 4094
而此时,新磁盘也自动online了。

点击(此处)折叠或打开

  1. select name,state from v$asm_disk;

  2. NAME STATE
  3. ---------- ----------------
  4. VD3 NORMAL
  5. OCR1 NORMAL
此时ASM已经可以正常运行,asmlib却仍然将旧设备标记为ASM磁盘

点击(此处)折叠或打开

  1. # oracleasm querydisk /dev/sdc1
  2. Device "/dev/sdc1" is marked an ASM disk with the label "OCR1"

点击(此处)折叠或打开

  1. //删除旧标记
  2. # oracleasm deletedisk /dev/sdc1
  3. Clearing disk header: done
  4. Dropping disk: done

  5. //其他节点运行
  6. oracleasm scandisks
由于新更换的设备路径是裸设备,不是asmlib,所以不要在asmlib中创建。

至此,全部完成。

请使用浏览器的分享功能分享到微信等