Thursday, January 17, 2013

ORACLE - Non-ASM to ASM migration

How to move/migrate non-asm file syatem into asm  ?
1.Restore control file
2.Restore non-system data files
3.Restore database
4.Restore Redolog files (see my notes: ORACLE - Redolog files)
5.Restrore Temporary Tablespace  (see my notes: ORACLE - TEMP files )

1) Restore controlfile from NON-ASM to ASM :
select name from v$controlfile;
/u01/app/oracle/oradata/jdb/control01.ctl
/u01/app/oracle/oradata/jdb/control02.ctl

Modify the spfile and create pfile:
show parameter db_create [To check the asm disk group]
alter system set control_files='+jdata'scope=spfile;
alter system set  db_create_file_dest='+jdata' scope=spfile;
create pfile ='/tmp/new_pfile.ora' from spfile;  

Create a new pfile, startup with mount option and restore the control file:
Startup database nomount;
sql> startup nomount pfile='/tmp/new_pfile.ora'

rman target /
rman>restore controlfile to '+jdata' from '/u01/app/oracle/oradata/jdb/control01.ctl';
rman>sql 'alter database mount';

2) Restore datafiles   from NON-ASM to ASM:

Option 1)  Mount the database, copy the datafile into using rman and rename the data file:
select tablespace_name, file_name from dba_data_files;
TABLESPACE_NAME                FILE_NAME                                               
------------------------------ ------------------------------------------------------
USERS                          /u01/app/oracle/oradata/jdb/users01.dbf            
UNDOTBS1                 /u01/app/oracle/oradata/jdb/undotbs01.dbf        
SYSAUX                      /u01/app/oracle/oradata/jdb/sysaux01.dbf            
SYSTEM                      /u01/app/oracle/oradata/jdb/system01.dbf        
JXHIST_2013_1         +jdata/jdb/datafile/jxhist_2013_1.268.804772687
TB_JREFERENCE     +jdata/jdb/datafile/tb_jreference.269.804774715
TB_JTEST                   +jdata/jdb/datafile/tb_jtest.270.804863897   
7 rows selected.

rman target /
rman> copy datafile '/u01/app/oracle/oradata/jdb/users01.dbf' to '+jdata';
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=192 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/JDB/users01.dbf
output file name=+jdata/jdb/datafile/users.277.804975705 tag=TAG20130117T202145 RECID=1 STAMP=80
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

startup mount
sql> alter database rename file '/u01/app/oracle/oradata/jdb/users01.dbf' to '+jdata/jdb/datafile/users.277.804975705';
sql>alter database open;

Option 2)  Offline the tablespace (non -system), copy the datafile into asm using rman and rename the data files:
alter tablespace users offline;
rman target /
copy datafile '/u01/app/oracle/oradata/jdb/users01.dbf' to '+jdata';
( get asm datafile name from rman output - see above)

sqlplus / as sysdba
alter database rename file '/u01/app/oracle/oradata/jdb/users01.dbf' to '+jdata/jdb/datafile/uses01.264.685642227';
alter tablespace users online;

3)Restore database from NON-ASM to asm: Mount the database and backup the database with asm format, update the control file and recover the database -
startup nomount;
$ rman target /
rman> restore controlfile to '+jdata' from '/u01/app/oracle/oradata/jdb/control01.ctl';
rman> sql 'alter database mount';
rman> backup as copy database format '+jdata'; [copy of whole database into new disk format]
rman> switch database to copy;[copy is created at new diskgroup now update control file]
rman> recover database;
rman> sql 'alter database open resetlogs';
rman> exit

No comments:

Post a Comment