Saturday, January 12, 2013

Rename/Change Location Datafile in ASM


To renamee/change location a datafile in ASM I followed below steps:

*** Considering database in archivelog mode

1. File the target file to rename.
select * from dba_data_files where tablespace_name='TBS_DW' order by file_name desc;

2. Put the file to offline from RMAN
SQL> ALTER DATABASE DATAFILE '+SYSTEMDG/oradb/datafile/tbs_dw.276.780864751' OFFLINE;

3. Execute copy from RAMN to the new location
RMAN> 
run{
allocate channel c1 device type disk;
COPY DATAFILE '+SYSTEMDG/oradb/datafile/tbs_dw.276.780864751' TO '+DATA1';
release channel c1;
}
---------- OUTPUT ---------
Starting backup at 17-APR-12
channel c1: starting datafile copy
input datafile file number=00631 name=+SYSTEMDG/oradb/datafile/tbs_dw.276.780864751
output file name=+DATA1/oradb/datafile/tbs_dw.915.780866609 tag=TAG20120417T192328 RECID=3 STAMP=780870208 --<<< use name of output file in the next rename stage
channel c1: datafile copy complete, elapsed time: 00:00:25
Finished backup at 17-APR-12
---------------------------

4. Rename the file from RMAN
RMAN> run {
allocate channel c1 device type disk;
set newname for datafile '+SYSTEMDG/oradb/datafile/tbs_dw.276.780864751' to '+DATA1/oradb/datafile/tbs_dw.915.780866609';
switch datafile all;
release channel c1;

---------- OUTPUT ---------
SQL> RECOVER DATAFILE '+DATA1/oradb/datafile/tbs_dw.915.780866609';
ORA-00279: change 3110310780083 generated at 04/17/2012 19:42:29 needed for
thread 8
ORA-00289: suggestion :
+RECO/oradb/archivelog/2012_04_17/thread_8_seq_692.1501.780864785
ORA-00280: change 3110310780083 for thread 8 is in sequence #692

Specify log: {=suggested | filename | AUTO | CANCEL}  -----<<< just enter
+RECO/oradb/archivelog/2012_04_17/thread_8_seq_692.1501.780864785
---------------------------

5. make the copied file online
SQL> ALTER DATABASE DATAFILE '+DATA1/oradb/datafile/tbs_dw.915.780866609' ONLINE;

6. check the file names again.
select * from dba_data_files where tablespace_name='TBS_DW' order by file_name desc;

7. drop using the old name
ASM: SQL> ALTER DISKGROUP ASMDSK2 DROP FILE tbs_dw.276.780864751;

1 comment: