Monday, December 21, 2009

Move datafile to new location with RMAN.

This is the new way to move datafile by using RMAN.
My goal for this situation is to move datafile of index partition to another ASM DISKGROUP, so in this sample I will show you move data file from +DATA1 to +DATA2

First Step : find the file number of datafile in sqlplus

SQL> select b.file#, c.name from v$tablespace a, v$datafile b, v$dbfile c where a.TS# = b.TS# and b.FILE# = c.FILE# and a.NAME like 'INDX_XXX_PART01_01%';

247,+DATA1/dmcdb/datafile/indx_xxx_part01_01.454.691783655

Second Step: Using the RMAN to backup datafile copy and switch datafile to use the new one.

rman> connect target /
rman> backup as copy datafile 247 format '+DATA2';
rman> sql 'ALTER DATABASE DATAFILE 247 OFFLINE';
rman> SWITCH DATAFILE 247 TO COPY;
rman> RECOVER DATAFILE 247;
rman> sql 'ALTER DATABASE DATAFILE 247 ONLINE';
rman> delete datafilecopy '+DATA1/dmcdb/datafile/indx_xxx_part01_01.454.691783655';

Final Step: Check the new location of datafile that you moved.

SQL> select b.file#, c.name from v$tablespace a, v$datafile b, v$dbfile c where a.TS# = b.TS# and b.FILE# = c.FILE# and a.NAME like 'INDX_XXX_PART01_01%';

247,+DATA2/dmcdb/datafile/indx_xxx_part01_01.490.691783739


== TaTsHuYa ==

No comments: