How to move ASM database files from one diskgroup to another

yyp2009發表於2014-06-12

 

原來資料檔案:
ASMCMD> pwd
+sysdg/UIMDB/datafile
ASMCMD> ls
SYSAUX.257.840633371
SYSTEM.256.840633371
TEST.263.843647081
UIMDB_DATA.264.843647213
UIMDB_DATA.265.843647325
UIMDB_DATA.266.843664683
UIMDB_DATA.267.843665385
UIMDB_DATA01
UIMDB_DATA02
UIMDB_DATA03
UIMDB_DATA04
UNDOTBS1.258.840633371
UNDOTBS2.261.840633651
USER01
USERS.259.840633373
USERS.268.843733425
test
ASMCMD> pwd

+sysdg/UIMDB/datafile
SQL> SELECT FILE_NAME FROM DBA_DATA_FILES;

FILE_NAME
--------------------------------------------------------------------------------
+SYSDG/uimdb/datafile/users.259.840633373
+SYSDG/uimdb/datafile/undotbs1.258.840633371
+SYSDG/uimdb/datafile/sysaux.257.840633371
+SYSDG/uimdb/datafile/system.256.840633371
+SYSDG/uimdb/datafile/undotbs2.261.840633651
+UIMDATA1/uimdb/datafile/data01.dbf
+UIMDATA1/uimdb/datafile/uimdb_data.268.850040055
+SYSDG/uimdb/datafile/uimdb_data02
+UIMDATA1/uimdb/datafile/uimdb_index01
+SYSDG/uimdb/datafile/uimdb_data03
+UIMDATA1/uimdb/datafile/uimdb_index02

FILE_NAME
--------------------------------------------------------------------------------
+SYSDG/uimdb/datafile/uimdb_data04
+UIMDATA1/uimdb/datafile/uimdb_index03
+SYSDG/uimdb/datafile/user01
+UIMDATA1/uimdb/datafile/itsm_data01.dbf

15 rows selected.


修改後:
ASMCMD> pwd
+UIMDATA1/UIMDB/datafile
ASMCMD> ls
JTITSM.266.844964315
UIMDB_DATA.268.850040055
UIMDB_DATA.269.850040495
UIMDB_DATA.270.850040577
UIMDB_DATA.271.850041291
UIMDB_INDEX.263.843647479
UIMDB_INDEX.264.843664795
UIMDB_INDEX.265.843686027
UIMDB_INDEX01
UIMDB_INDEX02
UIMDB_INDEX03
USERS.272.850041359
data01.dbf
itsm_data01.dbf

ASMCMD>

 

FILE_NAME
--------------------------------------------------------------------------------
+SYSDG/uimdb/datafile/users.259.840633373
+SYSDG/uimdb/datafile/undotbs1.258.840633371
+SYSDG/uimdb/datafile/sysaux.257.840633371
+SYSDG/uimdb/datafile/system.256.840633371
+SYSDG/uimdb/datafile/undotbs2.261.840633651
+UIMDATA1/uimdb/datafile/data01.dbf
+UIMDATA1/uimdb/datafile/uimdb_data.268.850040055
+UIMDATA1/uimdb/datafile/uimdb_data.269.850040495
+UIMDATA1/uimdb/datafile/uimdb_index01
+UIMDATA1/uimdb/datafile/uimdb_data.270.850040577
+UIMDATA1/uimdb/datafile/uimdb_index02

FILE_NAME
--------------------------------------------------------------------------------
+UIMDATA1/uimdb/datafile/uimdb_data.271.850041291
+UIMDATA1/uimdb/datafile/uimdb_index03
+UIMDATA1/uimdb/datafile/users.272.850041359
+UIMDATA1/uimdb/datafile/itsm_data01.dbf
+UIMDATA1/uimdb/datafile/uimdb_index04
+UIMDATA1/uimdb/datafile/uimdb_index05

17 rows selected.

SQL>

 

 

處理步驟:

1 把原來的datafile進行offline:

SQL>  ALTER DATABASE DATAFILE '+SYSDG/uimdb/datafile/uimdb_data02' offline;
Database altered.
SQL>   ALTER DATABASE DATAFILE '+SYSDG/uimdb/datafile/uimdb_data03' offline;
2 用rman進行cp
rman:copy datafile '+SYSDG/uimdb/datafile/user01' to '+UIMDATA1';
RMAN> copy datafile '+SYSDG/uimdb/datafile/uimdb_data02' to '+UIMDATA1';

Starting backup at 12-JUN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5796 instance=uimdb1 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=+SYSDG/uimdb/datafile/uimdb_data02

output file name=+UIMDATA1/uimdb/datafile/uimdb_data.269.850040495 tag=TAG20140612T102134 RECID=3 STAMP=850040564
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
Finished backup at 12-JUN-14

Starting Control File and SPFILE Autobackup at 12-JUN-14
piece handle=+FRADG/uimdb/autobackup/2014_06_12/s_850040570.411.850040571 comment=NONE
Finished Control File and SPFILE Autobackup at 12-JUN-14

3 用rman進行改路徑:
run {
set newname for datafile '+SYSDG/uimdb/datafile/user01'  to '+UIMDATA1/uimdb/datafile/users.272.850041359';
switch datafile all;
             }

RMAN> run {
2> set newname for datafile '+SYSDG/uimdb/datafile/uimdb_data03'  to '+UIMDATA1/uimdb/datafile/uimdb_data.270.850040577';
3> switch datafile all;
4>              }

executing command: SET NEWNAME
datafile 10 switched to datafile copy
input datafile copy RECID=4 STAMP=850040646 file name=+UIMDATA1/uimdb/datafile/uimdb_data.270.850040577
            
註釋:
新位置檔名稱從如下outputfile中新取得:
RMAN> copy datafile '+SYSDG/uimdb/datafile/uimdb_data03' to '+UIMDATA1';

Starting backup at 12-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00010 name=+SYSDG/uimdb/datafile/uimdb_data03
output file name=+UIMDATA1/uimdb/datafile/uimdb_data.270.850040577 tag=TAG20140612T102256 RECID=4 STAMP=850040646
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
Finished backup at 12-JUN-14

Starting Control File and SPFILE Autobackup at 12-JUN-14
piece handle=+FRADG/uimdb/autobackup/2014_06_12/s_850040652.394.850040653 comment=NONE
Finished Control File and SPFILE Autobackup at 12-JUN-14
            
3 sqlplus進行恢復:
SQL>  RECOVER DATAFILE  '+UIMDATA1/uimdb/datafile/uimdb_data.268.850040055';
Media recovery complete.
SQL>
4 sqlplus進行online:
SQL> ALTER DATABASE DATAFILE '+UIMDATA1/uimdb/datafile/uimdb_data.268.850040055' online;
Database altered.
SQL> SELECT FILE_NAME FROM DBA_DATA_FILES;

5 最後到進入asm,刪除原來的datafile:
ASMCMD> rm UIMDB_DATA0*
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD> ls
SYSAUX.257.840633371
SYSTEM.256.840633371
TEST.263.843647081
UNDOTBS1.258.840633371
UNDOTBS2.261.840633651
USER01
USERS.259.840633373
USERS.268.843733425


reference:
How to move ASM database files from one diskgroup to another ? (文件 ID 330103.1)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13750068/viewspace-1181137/,如需轉載,請註明出處,否則將追究法律責任。

相關文章