RMAN DUPLICATE DATABASE USING BACKUP WITH CONNECTION TO TARGET DATABASE
In this post, I will demonstrate how to duplicate a database using its backups.
This method requires connection with the target database also to read its controlfile
to get information about the backups.
********************************
source database orcl
Duplicate database orclt
***********************************
Overview :
on the source host
- Backup Database , Archivelogs and controlfile
- Copy these backup files to the server where you want to create the duplicate copy.
- Creat Pfile from source database
on the target host
- Add a line in the file /etc/oratab to reflect the database instance(orclt) you are going to copy
- create folders
- Copy the initialization parameter file from the source database add edit it.
- Copy the password file
- Startup the duplicate database (orclt) in nomount mode using modified parameter file
- Using RMAN connect to the source database(orcl) as target database and duplicate database
(orclt) as auxiliary instance
- duplicate the database orcl to orclt
Implementation :
———————-
on the source host
———————-
– Make a folder to stage the backup
oracle$mkdir /home/oracle/stage
– Take the backup of the source database
oracle$. oraenv orcl
rman target /
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;
backup database plus archivelog format ‘/home/oracle/stage/%U.rmb';
The controlfile backup is also required. If you have configured the controlfile
autobackup, the backup would contain the controlfile as well. If you want to be sure,
ors you have not configured controlfile autobackup, you can backup the controlfile
explicitly.
——-
- Creat Pfile from source database
——-
SQL>Create pfile=’/u01/app/oracle/oradata/orcl/initsource.ora’
from spfile;
———————————————–
The rest of the steps occur on the target host.
———————————————–
———————————
Copy the backup files to the server where you want to create the duplicate copy.
——————————-
$mkdir -p /home/oracle/stage
scp sourcehost:/home/oracle/stage/*.rmb desthost::/home/oracle/stage/
– Add a line in the file /etc/oratab to reflect the database instance you are going to copy:
orclt:/u01/app/oracle/product/11.2.0/db1:N
– Now set the Oracle SID as the duplicated database SID:
# . oraenv
ORACLE_SID = [orclt] ?
– create folders
$mkdir -p /u01/app/oracle/oradata/orclt
mkdir -p /u01/app/oracle/flash_recovery_area/orclt
mkdir -p /u01/app/oracle/admin/orclt/adump
mkdir -p /u01/app/oracle/admin/orclt/dpdump
– Copy the initialization parameter file from the main database.
– If u are duplicating on the same host
$cp /u01/app/oracle/oradata/orcl/initsource.ora /u01/app/oracle/oradata/orclt/inittarget.ora
OR
– If u are duplicating on the different host
$scp soucehost:/u01/app/oracle/oradata/orcl/initsource.ora /u01/app/oracle/oradata/orclt/inittarget.ora
– Edit pfile
$vi /u01/app/oracle/oradata/orclt/inittarget.ora
– Change db_name = orclt
– Edit it to reflect the new locations that might be appropriate
such as control file locations,audit dump destinations, datafile
locations, etc.
– add these lines –
db_file_name_convert = (“/u01/app/oracle/oradata/orcl”,
“/u01/app/oracle/oradata/orclt”)
log_file_name_convert = (“/u01/app/oracle/oradata/orcl”,
“/u01/app/oracle/oradata/orclt”)
In case source and destination databases ae ASM, following lines can be added :
db_file_name_convert = (“+DATA/orcl”,”+DATA/orclt”)
log_file_name_convert = (“+DATA/orcl”,”+DATA/orclt”, “+FRA/orcl”,”+FRA/orclt”)
————————————–
– Copy the password file as well
$ cp /u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl /u01/app/oracle/product/11.2.0/db_1/dbs/orapworclt
OR
$ scp sourcehost:/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl /u01/app/oracle/product/11.2.0/db_1/dbs/orapworclt
$ . oraenv
ORACLE_SID = [orclt] ?
– Startup the duplicate database in nomount mode using modified parameter file
$sqlplus sys/oracle as sysdba
SQL> startup nomount pfile=’/u01/app/oracle/oradata/orclt/inittarget.ora';
create spfile from pfile=’/u01/app/oracle/oradata/orclt/inittarget.ora';
- Using RMAN connect to the source database(orcl) as target database and duplicate database
(orclt) as auxiliary instance
$. oraenv
orclt
$rman target sys/oracle@orcl auxiliary /
– duplicate the database orcl to orclt
– the command performs the following steps:
* Creates an SPFILE
* Shuts down the instance and restarts it with the new spfile
* Restores the controlfile from the backup
* Mounts the database
* Performs restore of the datafiles. In this stage it creates the files in the
converted names.
* Recovers the datafiles up to the time specified and opens the database
RMAN>duplicate target database to orclt;
– check that duplicate database is up
$sqlplus / as sysdba
sql>conn hr/hr
select * from tab;
– Note that DBID is different from the main database so it can be backed up
independently and using the same catalog as well.
SQL> select dbid from v$database;
DBID
———-
3779358555
conn sys/oracle@orcl as sysdba
select dbid from v$database;
DBID
———-
1326904854
No comments:
Post a Comment