Académique Documents
Professionnel Documents
Culture Documents
The 10G flashback database feature allows us to rewind the database to a previous point in
time. But what when we haven' t enabled flashback database ? or what when we have to
recover the database to a previous point in time of which the database SCN falls out of the
flashback database retention window ?
In these circumstances we still have to do an old fashionned (partial) restore of a backup and
recover forward up to the SCN we want.
Obviously we need a valid backup and archivelogs. We will see it is a piece of cake (very easy
task) but it can be time consuming.
With the example below I clone the database MY_DB ( sid= MYDB ) to database BK on the
same platform and recover it to a previous point in time. Note
1. I use OMF - Oracle Managed Files - and as such I specify the db_create_file_dest and db_c
reate_online_log_dest_n
parameters
2. I restore the entire db otherwise I would have used the skip tablespace command
3. Backups of the source database - the one we wanna clone - are made with RMAN
4. off course the database operates in archivelog mode and have I still the required archivelogs
on disk.
1 / 13
Clone database with RMAN on the same host
3. I use the timestamp_to_scn function to retrieve the scn to which I have to recover
4. I use rman' s duplicate target database to "destination database name" + "until scn desired
SCN"
5. I drink a coffee while RMAN is doing yet another time such a great recovery work.
oracle@myhost:/home/oracle $ cd $ORACLE_HOME/dbs
NAME
/opt/oracle/MY_DB/controlfile/o1_mf_38q6k2z7_.ctl
/opt/oradata/MY_DB/controlfile/o1_mf_38q6k3pj_.ctl
2 / 13
Clone database with RMAN on the same host
CURRENT_SCN
6488614
SCN_TO_TIMESTAMP(CURRENT_SCN)
17-MAR-08 10.10.16.000000000 AM
TIMESTAMP_TO_SCN('17-MAR-0808.00.00.000000000AM')
6485576
We clone the spfile and have some modifications in it ( db_name, db_unique_name, ... )
3 / 13
Clone database with RMAN on the same host
- .db_create_file_dest='/mnt/oradata/bk'
- .db_unique_name='bk'
- .db_create_online_log_dest_1='/opt/oracle'
- .db_create_online_log_dest_2='/opt/oradata'
Before starting the clone operation I manually set the NLS_LANG environment and we startup
nomount the bk instance
export ORACLE_SID=bk
export NLS_LANG=american_america.AL32UTF8
SQL> exit;
We connect with RMAN to the source database - the one we wanna clone - and we use the
auxiliary command to connect with the previously started instance bk
4 / 13
Clone database with RMAN on the same host
And we are ready to invoke the clone operation, note we just type the 2 command lines below
and RMAN is doing everything for us. You may want to tail -f the new alertfile of the new
database.
5 / 13
Clone database with RMAN on the same host
6 / 13
Clone database with RMAN on the same host
database dismounted
Oracle instance shut down
7 / 13
Clone database with RMAN on the same host
8 / 13
Clone database with RMAN on the same host
9 / 13
Clone database with RMAN on the same host
database opened
Finished Duplicate Db at 17-MAR-08
10 / 13
Clone database with RMAN on the same host
Still there ? Where are the new datafiles, controlfiles, redolog files and tempfiles ?
Apparently they are created in
1. SET NEWNAME
2. DB_FILE_NAME_CONVERT
3. LOG_FILE_NAME_CONVERT
MEMBER
/opt/oracle/BK/onlinelog/o1_mf_8_3xwk4pdk_.log
/opt/oradata/BK/onlinelog/o1_mf_8_3xwk52o1_.log
/opt/oracle/BK/onlinelog/o1_mf_7_3xwk3vx0_.log
/opt/oradata/BK/onlinelog/o1_mf_7_3xwk4cko_.log
/opt/oracle/BK/onlinelog/o1_mf_6_3xwk2vqc_.log
/opt/oradata/BK/onlinelog/o1_mf_6_3xwk3c23_.log
/opt/oracle/BK/onlinelog/o1_mf_5_3xwk1ypf_.log
/opt/oradata/BK/onlinelog/o1_mf_5_3xwk2fv0_.log
/opt/oracle/BK/onlinelog/o1_mf_4_3xwk1239_.log
/opt/oradata/BK/onlinelog/o1_mf_4_3xwk1khh_.log
10 rows selected.
NAME
11 / 13
Clone database with RMAN on the same host
/opt/oracle/BK/controlfile/o1_mf_3xwk0q83_.ctl
/opt/oradata/BK/controlfile/o1_mf_3xwk0r1s_.ctl
NAME
/mnt/oradata/bk/BK/datafile/o1_mf_temp_3xwk5mm4_.tmp
/mnt/oradata/bk/BK/datafile/o1_mf_temp01_3xwk5n1y_.tmp
/mnt/oradata/bk/BK/datafile/o1_mf_temp02_3xwk5nft_.tmp
NAME
/mnt/oradata/bk/BK/datafile/o1_mf_system_3xwhjd07_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_undotbs1_3xwhjd88_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_sysaux_3xwhjdf6_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_users_3xwhjdor_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_a_3xwhjdtg_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_l_3xwhjdyr_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_l_3xwhjfc9_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_l_3xwhjg2c_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_l_3xwhlomx_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_l_3xwhvjy0_.dbf
/mnt/oradata/bk/BK/datafile/o1_mf_ts_mydb_l_3xwhvko2_.dbf
DBID
12 / 13
Clone database with RMAN on the same host
589716967
DBID
3954204418
When we clone a database with RMAN' duplicate indicated as above there will be a new dbid.
When we clone a database with RMAN' duplicate for standby the dbid of both primary and
standby will stay equal ( which is mandatory )
13 / 13