RAC数据库存储在线不停机更换方案

一、     方案背景

       本次迁移是针对ORACLE 11GR2 RAC的存储进行本地切换迁移,由于数据库文件数目较多,数据量大,并且停机时间限制较大,故用传统的数据文件移动,需要offline离线业务表空间,并且数据库系统数据文件需要在非打开状态下做迁移,对业务造成较大的暂停影响,并且操作过程容易出现细节错误,故考虑采用11G ASM的在线rebalance功能,将ASM数据库文件平移至新存储,以下是介绍这个方案的具体实施步骤,具体是参照ORACLE官方文档进行配置实施。

 

二、     RAC集群系统迁移

参考文档“How to Swap Voting Disks Across Storage ina Diskgroup (文档 ID1558007.1)”,对RAC的OCR,VOTEING DISK进行存储间切换,操作步骤如下:

1)        当前存储信息:
以下ODS库ASM数据磁盘组、OCR、VOTE信息:

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  NORMAL N   512   4096 1048576      6141     5215     2047    1584             0          Y    VGCRS/

MOUNTED  EXTERN  N    512  4096  1048576   3071958   24465       0    24465             0           N    VGDATA/

当前ASM有VGDATA,VGCRS 两个磁盘组,总大小3TB左右,以下是各磁盘组磁盘信息:

select NAME,PATH,total_mb,free_mb from v$asm_disk;

NAME                           PATH                                                                               TOTAL_MB    FREE_MB

------------------------------------------------------------------------------------------------------------------------ ----------

VGDATA_0005                    /dev/oracleasm/disks/ASM_DATA06                                                     511993       4086

VGDATA_0004                   /dev/oracleasm/disks/ASM_DATA05                                                     511993       4090

VGDATA_0003                   /dev/oracleasm/disks/ASM_DATA04                                                     511993       4104

VGDATA_0002                   /dev/oracleasm/disks/ASM_DATA03                                                     511993       4061

VGDATA_0001                   /dev/oracleasm/disks/ASM_DATA02                                                     511993       4058

VGDATA_0000                   /dev/oracleasm/disks/ASM_DATA01                                                     511993       4066

VGCRS_0002                    /dev/oracleasm/disks/ASM_CRS03                                                        2047       1740

VGCRS_0001                    /dev/oracleasm/disks/ASM_CRS02                                                        2047       1737

VGCRS_0000                    /dev/oracleasm/disks/ASM_CRS01                                                         2047       1738

9rows selected

查看当前VGCRS的信息:

image.png

2)        划分VGCRS新存储的磁盘LUN:

这一步前提是对新存储划分磁盘,并且是通过oracleasm包创建ASM可识别的磁盘,

划分要求是:

1,  名称跟下面路径下的红色ASM磁盘name名称一致,

2,  每个CRS磁盘磁盘成员为2G大小,

3,  权限一定要跟原有的磁盘成员一致;

4,  注意多路径等问题。

具体可参考文档“如何在 RAC 集群或单机 ASM 环境中对已经存在的 Diskgroup 添加新磁盘(文档 ID 1946668.1)”,建议由集成人员实施。

3)        通过oracleasm包配置ASM新磁盘(参考)

创建VGCRS磁盘组对应的新磁盘,这里假设是/dev/sdq*

/etc/init.d/oracleasmcreatedisk  ASM_CRS4  /dev/sdq1
/etc/init.d/oracleasm createdisk  ASM_CRS5 /dev/sdq2
/etc/init.d/oracleasm createdisk  ASM_CRS6 /dev/sdq3

4)        增加VGCRS磁盘组的冗余成员

参考官方(文档 ID 1558007.1),增加VGCRS磁盘组的磁盘成员,并做切换:

sqlplus  " / assysasm"
ALTER  DISKGROUP  VGCRS  ADD  

FAILGROUP  VGCRS_0000  DISK  '/dev/oracleasm/disks/ASM_CRS04'

FAILGROUP  VGCRS_0001  DISK  '/dev/oracleasm/disks/ASM_CRS05'

FAILGROUP  VGCRS_0002  DISK  '/dev/oracleasm/disks/ASM_CRS06';

5)        通过gv$asm_operation视图查rebalance进度,如发现没有记录,则表示rebalance内部操作已完成:

 Monitor that the rebalance completed, check gv$asm_operation till it returns no rows.

6)       完成后确定rebalance后的成员信息,并删除旧成员:

select dg.name, d.path, d.failgroup, d.failgroup_type

  from v$asm_diskgroup dg, v$asm_disk d

 where dg.group_number = d.group_number

   and dg.name = 'VGCRS'

 order by dg.name, d.path, d.failgroup;

确定新成员存在后,删除旧存储的成员:

ALTERDISKGROUP VGCRS  drop disk  
' ASM_CRS01',
' ASM_CRS02',
' ASM_CRS03';

7)        最后确认现有成员:

select dg.name,d.path, d.failgroup, d.failgroup_type

  from v$asm_diskgroup dg, v$asm_disk d

 where dg.group_number = d.group_number

   and dg.name = 'VGCRS'

 order by dg.name, d.path, d.failgroup;

 

三、     RAC数据库迁移

参考“零宕机时间迁移 ASM 磁盘组到另一个 SAN磁盘阵列DAS 的准确步骤(文档 ID1946664.1)”

下面对数据库部分迁移,下面这种是在线做ASM磁盘组的rebalance:
 

1)        创建VGDATA磁盘组对应的新磁盘,这里假设是下列磁盘:

/etc/init.d/oracleasm createdisk  ASM_DATA_01  /dev/sdj1
/etc/init.d/oracleasm createdisk  ASM_DATA_02 /dev/sdk1
/etc/init.d/oracleasm createdisk  ASM_DATA_03 /dev/sdl1
/etc/init.d/oracleasm createdisk  ASM_DATA_04 /dev/sdm1
/etc/init.d/oracleasm createdisk  ASM_DATA_05 /dev/sdn1
/etc/init.d/oracleasm createdisk  ASM_DATA_06 /dev/sdo1

划分要求是:

A.     名称跟下面路径下的红色ASM磁盘name名称一致,

B.     每个CRS磁盘磁盘成员为2G大小,

C.     权限一定要跟原有的磁盘成员一致;

D.     注意多路径等问题。

具体可参考文档“如何在 RAC 集群或单机 ASM 环境中对已经存在的 Diskgroup 添加新磁盘(文档 ID 1946668.1)”,建议由集成人员实施。

2)        增加新磁盘到目标磁盘组:

alter diskgroup VGDATA add disk 
'/dev/oracleasm/disks/ASM_DATA_01', 
'/dev/oracleasm/disks/ASM_DATA_02',
'/dev/oracleasm/disks/ASM_DATA_03',
'/dev/oracleasm/disks/ASM_DATA_04',
'/dev/oracleasm/disks/ASM_DATA_05',
'/dev/oracleasm/disks/ASM_DATA_06'rebalance power 11;

注意:这里新磁盘的名称跟原来的名称是ASM_DATA01和ASM_DATA_01,多了_ 字符!

3)        接下来等待重平衡操作完成:

SQL> select * fromv$asm_operation; 
SQL> select * from gv$asm_operation;

4)        最后,移除旧磁盘:

alter diskgroup VGDATA DROP disk 
'/dev/oracleasm/disks/ASM_DATA01', 
'/dev/oracleasm/disks/ASM_DATA02',
'/dev/oracleasm/disks/ASM_DATA03',
'/dev/oracleasm/disks/ASM_DATA04',
'/dev/oracleasm/disks/ASM_DATA05',
'/dev/oracleasm/disks/ASM_DATA06'rebalance power 11

5)        接下来等待重平衡操作完成:

SQL> select * fromv$asm_operation; 
SQL> select * from gv$asm_operation;

6)        待上述过程完成后,再一次对ASM磁盘确认:

select a.NAME GROUP_NAME,a.TOTAL_MB,a.FREE_MBGROUP_FREE_MB,b.OS_MB,b.FREE_MB,b.name,b.path from v$asm_diskgroup a,v$asm_diskb where a.GROUP_NUMBER=b.GROUP_NUMBER;

至此, ASM 磁盘组和数据库已经迁移到了新的存储上面。