Oracle數據庫文件部署在ASM上,需要盡量短的停機時間完成此次存儲更換。由於不涉及異構的遷移轉換,遷移起來也不難,無需借助三方的工具來完成這次高可用切換。因此使用ASM的熱添加和刪除磁盤的方式完成存儲遷移, 該方法可以實現遷移過程中系統的零停機,但整個操作進度不可控,數據重組過程中無法把握進度和風險,所以慎用。
【正文】
首先,介紹遷移的簡單過程。步驟如下:
劃分raw或者asm disk,並檢查或更改asm參數,例如asm_disktring,使得新存儲的asm disk對ASM實例可識別。
備份OCR、Voting Disk、ASM disk header和數據庫。
將新存儲disk添加到現有的asm diskgroup中。
刪除舊存儲對應的asm disk。
觀察期。
本文重點介紹ASM的熱添加和刪除磁盤技術,所以第1、2步在此不列出,由第3步開始。
一 添加ASM磁盤
下面開始添加asm磁盤,這裡使用ASM的REBALANCE技術來解決在線遷移數據。
1.1 查看當前ASM磁盤信息
登錄到ASM實例,查看當前磁盤組的信息:
[root@node1 ~]# su - grid
node1-> sqlplus / as sysasm
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jun 5 11:20:02 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> select instance_name from v$instance;
INSTANCE_NAME
------------------------------------------------
+ASM1
SQL> col name for a10
SQL> set linesize 150
SQL> select NAME, ALLOCATION_UNIT_SIZE, STATE, TOTAL_MB, FREE_MB USABLE_FILE_MB from gv$asm_diskgroup;
NAME ALLOCATION_UNIT_SIZE STATE TOTAL_MB USABLE_FILE_MB
---------- -------------------- --------------------------------- ---------- --------------
DAVA 1048576 MOUNTED 6144 4160
OCRVOTE 1048576 MOUNTED 1024 626
DAVA 1048576 MOUNTED 6144 4160
OCRVOTE 1048576 MOUNTED 1024 626
SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'OCRVOTE');
FAILGROUP NAME
-------------------- --------------------
OCRVOTE_0001 OCRVOTE_0001
OCRVOTE_0000 OCRVOTE_0000
SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'DAVA');
FAILGROUP NAME
-------------------- --------------------
DAVA_0000 DAVA_0000
1.2 添加磁盤
現往磁盤組ocrvote裡添加2個新創建的ASM磁盤,磁盤組dava添加1個新創建的ASM磁盤,並指定REBALANCE的速度10:
SQL> alter diskgroup ocrvote add disk '/dev/asm-diske' name OCRVOTE_0002 rebalance power 10;
Diskgroup altered.
SQL> alter diskgroup ocrvote add disk '/dev/asm-diskf' name OCRVOTE_0003 rebalance power 10;
Diskgroup altered.
SQL> alter diskgroup dava add disk '/dev/asm-diskg' name dava_0001 rebalance power 10;
Diskgroup altered.
備注:這裡只測試添加一個ASM磁盤,在真實環境中可能會增加多個,那麼采用如下方式:
alter diskgroup khm_data add disk 'ORCL:ASM1', 'ORCL:ASM2', 'ORCL:ASM3' REBALANCE POWER n;
當然,先添加磁盤後手動進行REBALANCE操作也可以。詳細的操作請查閱官方文檔。
1.3 查詢ASM磁盤組狀態
注意:REBALANCE過程根據數據量的大小不同完成時間也不一,可以針對當前系統情況指定合理的POWER值。
REBALANCE過程可以通過v$asm_operation視圖來查看:
SQL> set line 150
SQL> col ERROR_CODE for a5
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STATE POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ------------ ---------- ---------- ---------- ---------- ---------- -----------
ERROR_CODE
------------------------------------------------------------------------------------------------------------------------------------
2 REBAL RUN 10 10 89 100 158 0
REBALANCE完成後,查詢v$asm_operation記錄將消失:
SQL> select * from v$asm_operation;
no rows selected
添加ASM磁盤後的狀態:
SQL> select NAME, ALLOCATION_UNIT_SIZE, STATE, TOTAL_MB, FREE_MB USABLE_FILE_MB from gv$asm_diskgroup;
NAME ALLOCATION_UNIT_SIZE STATE TOTAL_MB USABLE_FILE_MB
-------------------- -------------------- --------------------------------- ---------- --------------
DAVA 1048576 MOUNTED 12288 10302
OCRVOTE 1048576 MOUNTED 2048 1646
DAVA 1048576 MOUNTED 12288 10302
OCRVOTE 1048576 MOUNTED 2048 1646
SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'OCRVOTE');
FAILGROUP NAME
-------------------- --------------------
OCRVOTE_0001 OCRVOTE_0001
OCRVOTE_0000 OCRVOTE_0000
OCRVOTE_0003 OCRVOTE_0003
OCRVOTE_0002 OCRVOTE_0002
SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'DAVA');
FAILGROUP NAME
-------------------- --------------------
DAVA_0000 DAVA_0000
DAVA_0001 DAVA_0001
磁盤順利添加至對應的磁盤組中。
二 刪除舊的ASM磁盤
現在就刪除舊的ASM磁盤,刪除的時候也可以指定rebalance速度:
2.1 刪除磁盤
磁盤組:ocrvote
SQL> alter diskgroup ocrvote drop disk OCRVOTE_0000 rebalance power 10;
Diskgroup altered.
SQL> alter diskgroup ocrvote drop disk OCRVOTE_0001 rebalance power 10;
Diskgroup altered.
磁盤組:DAVA
SQL> alter diskgroup dava drop disk DAVA_0000 rebalance power 10;
Diskgroup altered.
2.2 查詢ASM磁盤狀態
首先,完成舊的ASM磁盤刪除後,觀察rebalance情況:
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STATE POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ------------ ---------- ---------- ---------- ---------- ---------- -----------
ERROR_CODE
------------------------------------------------------------------------------------------------------------------------------------
1 REBAL RUN 10 10 129 1007 190 4
SQL> select * from v$asm_operation;
no rows selected
查詢沒有記錄,說明rebalance完成,確認無誤。
查詢刪除ASM磁盤後的狀態:
SQL> select NAME, ALLOCATION_UNIT_SIZE, STATE, TOTAL_MB, FREE_MB USABLE_FILE_MB from gv$asm_diskgroup;
NAME ALLOCATION_UNIT_SIZE STATE TOTAL_MB USABLE_FILE_MB
-------------------- -------------------- --------------------------------- ---------- --------------
DAVA 1048576 MOUNTED 6144 4158
OCRVOTE 1048576 MOUNTED 1024 626
DAVA 1048576 MOUNTED 6144 4158
OCRVOTE 1048576 MOUNTED 1024 626
SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'OCRVOTE');
FAILGROUP NAME
-------------------- --------------------
OCRVOTE_0003 OCRVOTE_0003
OCRVOTE_0002 OCRVOTE_0002
SQL> select failgroup, name from v$asm_disk where group_number=(select group_number from v$asm_diskgroup where name = 'DAVA');
FAILGROUP NAME
-------------------- --------------------
DAVA_0001 DAVA_0001