Вы находитесь на странице: 1из 3

Database using the Oracle RMAN DUPLICATE DATABASE feature

(using the disklevel/tape level backup)



Assumptions and Prerequisites

The following assumptions are made in this document.
A valid RMAN backup of the source database and archive log files exists. This includes the
backup of the controlfile as well.
The same directory structure exists on target server as compared to source server where the
RMAN backupsets are located.
Source and target database have the same SYS password
Note:
If the source and target database SYS passwords are different, we need to do either
a) Make a copy of the target database existing password file and copy the password file from the
$ORACLE_HOME/dbs location on source database server to same location on the target
database server.
b) Make a copy of the target database existing password file and recreate using the orapwd
command, but using the SYS password of the source database

Do note if the same file structure do not exists then you can use the below to set the newname during
installation and also before opening the database in resetlog you can rename and logfiles.
set head off pages 0 feed off echo off verify off
set lines 200
spool rename_files.lst
select SET NEWNAME FOR DATAFILE || FILE# || TO || /home/oracle/datafile/ ||
substr(name,instr(name,/,-1)+1) || ; from v$datafile;

select alter database rename file || member || ||chr(10)|| TO || /home/oracle/datafile/ ||
substr(member,instr(member,/,-1)+1) || ; from v

$logfile;
spool off
exit;

Also from v$tempfile rename the temp file.
Note: In this document we are not changing the datafile location it is assumed to have the same location
as the target database.
If you require to change the datafile location you can also use the below. Also if the datafile are in non
ASM and the clone database you want in ASM then also you can use the below parameters :
*.control_files=+DATA,+DATA ( note this will change and spfile will include the full
ASM file name)
*.db_create_file_dest=+DATA
*.db_create_online_log_dest_1=+DATA
*.db_create_online_log_dest_2=+DATA (this will multiplex the redo log files remove if not
required)
Note ensure the parameters db_file_name_convert and log_file_name_convert are NOT set.
Prepare the source database to enable auxiliary connection to the target
database
Update tnsnames.ora on the source database server
Create a TNS Alias for the auxiliary connection on the source database
$ORACLE_HOME/network/admin/tnsnames.ora
Cl onedb1aux =
( DESCRI PTI ON =
( ADDRESS_LI ST =
( ADDRESS = ( PROTOCOL = TCP) ( HOST = host name_i p_aux) ( PORT = 1521) )
)
( CONNECT_DATA =
( SERVI CE_NAME = col nedb1)
)
)
Prepare the target database to allow auxiliary connection from the source
database

Add a static entry in the listener.ora of the target database server
The GLOBAL_DBNAME entry will be used to reference the static service_name in the listener.
Add a static entry for the auxiliary connection in the target database
$ORACLE_HOME/network/admin/listener.ora

(SID_DESC =
(GLOBAL_DBNAME =clonedb1.mydomain)
(ORACLE_HOME =/node2/oracle/clonedb1 )
(SID_NAME = clonedb1)
)

Reload the listener
$> lsnrctl reload LISTENER
We create an Unix shell script duplicatedb.sh which will establish the auxiliary database connection and
execute the RMAN commands required to duplicate the database.
These are the contents of the Unix shell script duplicatedb.sh
rman target / auxiliary sys/syspwd@clonedb1aux <<EOF
run
{
allocate channel c1 type disk;
allocate auxiliary channel c2 type disk format '/node1/backup/SOURCEDB1/backupsets/%U';
--- set until sequence 63644 thread 1;
duplicate target database to clonedb1;
}
EOF

syspwd: This is the SYS password in the target database. As mentioned earlier, the SYS
password in both the source as well as target database needs to be the same.
Clonedb1: This is the tnsnames.ora alias which we had created earlier to connect to the
auxiliary instance.

Execute the script to perform the duplicate
./duplicatedb.sh > duplicatedb.log

Monitor the progress of the RMAN restore and recover operation
From another session we can monitor the progress of the DUPLICATE database operation by executing
the command:
tail -f duplicatedb.log

Check the location of the datafiles and online redo log files
sel ect name f r omv$dat af i l e;

sel ect member f r omv$l ogf i l e;

show par amet er cont r ol _f i l es

Вам также может понравиться