Moving datafiles for database using ASM
Individual datafile(s):
1. Take the datafile(s) in question offline.
(example)
alter database datafile 6 offline;
2. Login to ASM via asmcmd. Then copy the datafiles from current diskgroup to destination diskgroup.
(example)
asmcmd> cp +DG01/svc_ctm.dbf +DG01/prmrydb/datafile/svc_ctm.dbf
asmcmd> copy datafile '+DG01/svc_ctm.dbf' to '+DG01';
3. Login to database via sqlplus and rename the datafiles.
(example)
ALTER DATABASE RENAME FILE '+DG01/svc_ctm.dbf' to '+DG01/prmrydb/datafile/svc_ctm.dbf';
4. Login to RMAN or sqlplus to recover the datafile(s) and place datafile(s) online.
(example)
rman target /
RECOVER DATAFILE 6;
SQL 'alter database datafile 6 online';
----------------------------------------------
Individual tablespace(s):
You can complete the following steps all within RMAN:
connect target /
run{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk3 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk4 DEVICE TYPE DISK;
backup as copy tablespace <tbsp_name> format '+DG01';
release channel disk1;
release channel disk2;
release channel disk3;
release channel disk4;
}
sql 'alter tablespace <tbsp_name> offline';
switch tablespace <tbsp_name> to copy;
recover tablespace <tbsp_name> ;
sql 'alter tablespace <tbsp_name> online';
-------------------------------------
Entire database (this requires database outage):
You can complete the following steps all within RMAN:
connect target /
run{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk3 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk4 DEVICE TYPE DISK;
backup as copy database format '+DG01';
release channel disk1;
release channel disk2;
release channel disk3;
release channel disk4;
}
shutdown immediate;
startup mount;
switch database to copy;
recover database;
shutdown immediate;
startup;
list datafilecopy all;
delete datafilecopy all;
1. Take the datafile(s) in question offline.
(example)
alter database datafile 6 offline;
2. Login to ASM via asmcmd. Then copy the datafiles from current diskgroup to destination diskgroup.
(example)
asmcmd> cp +DG01/svc_ctm.dbf +DG01/prmrydb/datafile/svc_ctm.dbf
asmcmd> copy datafile '+DG01/svc_ctm.dbf' to '+DG01';
3. Login to database via sqlplus and rename the datafiles.
(example)
ALTER DATABASE RENAME FILE '+DG01/svc_ctm.dbf' to '+DG01/prmrydb/datafile/svc_ctm.dbf';
4. Login to RMAN or sqlplus to recover the datafile(s) and place datafile(s) online.
(example)
rman target /
RECOVER DATAFILE 6;
SQL 'alter database datafile 6 online';
----------------------------------------------
Individual tablespace(s):
You can complete the following steps all within RMAN:
connect target /
run{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk3 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk4 DEVICE TYPE DISK;
backup as copy tablespace <tbsp_name> format '+DG01';
release channel disk1;
release channel disk2;
release channel disk3;
release channel disk4;
}
sql 'alter tablespace <tbsp_name> offline';
switch tablespace <tbsp_name> to copy;
recover tablespace <tbsp_name> ;
sql 'alter tablespace <tbsp_name> online';
list datafilecopy all;
delete datafilecopy all;
-------------------------------------
Entire database (this requires database outage):
You can complete the following steps all within RMAN:
connect target /
run{
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk3 DEVICE TYPE DISK;
ALLOCATE CHANNEL disk4 DEVICE TYPE DISK;
backup as copy database format '+DG01';
release channel disk1;
release channel disk2;
release channel disk3;
release channel disk4;
}
shutdown immediate;
startup mount;
switch database to copy;
recover database;
shutdown immediate;
startup;
list datafilecopy all;
delete datafilecopy all;
Comments