mercredi 6 juillet 2011

Moving a DB with Physical Copy


1/ Online Copy Using Archivelog mode + RECOVER for big DB

Interesting, because it will physically move the DB long before the application down-time. Recover will catch up users activity at the final moment in the down-time window.

1.1 DB Online Copy

Using either « Begin/End backup » or RMAN :

$ cat rma_rdb_dsk_noc.scr
connect target /
run { startup nomount; }
set dbid=1504614898 ;
run {
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data/<base>/rman/%F' ;
restore spfile from autobackup ;
}
shutdown immediate ;
startup nomount ;
set dbid=1504614898 ;
run {
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/data/<base>/rman/%F' ;
restore controlfile from autobackup ;
}
sql 'alter database mount' ;
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 ;
run {
set until logseq 909619 thread 1 ; # applies redo indluding logseq 909618
restore database ;
}

1.2 Manual Recover / Open resetlogs

Shutdown source DB
Copy needed archivelogs to Target

$ rcp -p *.arch srv2old:/work/<base>/arch

Then connect to SQL


SQL> recover database using backup controlfile ;
ORA-00279: change 7517916098 generated at 02/08/2011 08:56:50 needed for thread
1
ORA-00289: suggestion : /work/<base>/arch/A9096171601463026.arch
ORA-00280: change 7517916098 for thread 1 is in sequence #909617

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
...

ORA-00279: change 7522477772 generated at 02/09/2011 08:50:37 needed for thread
1
ORA-00289: suggestion : /work/<base>/arch/A9096431601463026.arch
ORA-00280: change 7522477772 for thread 1 is in sequence #909643
ORA-00278: log file '/work/<base>/arch/A9096421601463026.arch' no longer needed
for this recovery

ORA-00308: cannot open archived log '/work/<base>/arch/A9096431601463026.arch'
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 3

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.
SQL> alter database open resetlogs ;
Database altered.