To replicate a database using duplicate in Rman

Source: Internet
Author: User

Target Library and Replication library environment:os:linux Red Hat as 4DB version:10.2.0.1 1. Target Library and replication library informationThe target database in Rman refers to the library being replicated, and the copy library (duplicate database) refers to the new library generated after replication. For testing convenience, the directory structure settings for the copy library and the target library are the same.Target Library:ip:192.168.30.37Sid:oraclCopy Library:ip:192.168.30.43Sid:oraclbak 2. Steps on the Copy libraryYou do this if you need to install Oracle software (without creating a database) and you need to create an Oracle user . 2.1: Create password file (note that the name format of the password file under Linux is Orapw+sid)[[email protected] DBS] $CD $ORACLE _home/dbs
[[email protected] DBS] $orapwd file=orapworaclbak password=oracle entries=10 force=y 2.2: Create the following directoryMkdir-p/u01/app/oracle/admin/oracl/adump
Mkdir-p/u01/app/oracle/admin/oracl/bdump
Mkdir-p/u01/app/oracle/admin/oracl/cdump
Mkdir-p/u01/app/oracle/admin/oracl/dpdump
Mkdir-p/u01/app/oracle/admin/oracl/pfile
Mkdir-p/u01/app/oracle/admin/oracl/udump
Mkdir-p/u01/app/oracle/oradata/oracl
Mkdir-p/u01/app/oracle/flash_recovery_area 2.3: Create a SPFile file
Copy the pfile created on target (Initoracl.ora, create step reference 3.1) to duplicate, modify the parameters (*.db_name= ' Oraclbak '), and the others are consistent with the target library and create SPFile .Sql>connect/as sysdba;
Sql>create spfile from pfile= '/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora '; 2.4: Start the database to the Nomount state
sql>startup nomount; 2.5: Create a listener
[[email protected] DBS] $NETCA 2.6: Configure Tnsname
[[email protected] DBS] $netmgr Note To configure the connection to the replication duplicate library and to the destination target library. 3. How to proceed on the target library 3.1: Create a pfile filesql>create pfile= '/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora ' from SPFile; 3.2: Put the database in archive mode (this step can be omitted if the database is already in archive mode)
Sql>shutdown immediate;
Sql>startup Mount;
Sql>alter database Archivelog;
Sql>alter system set log_archive_dest_1= ' Location=/u01/app/oracle/duplicate ' Scope=both;
Sql>alter database open; 3.3: Back Up the database (my library has bad blocks, specified Maxcorrupt)$rman Target/
rman>run{
Set Maxcorrupt for datafile 5 to 20;
Allocate channel DUP type disk;
Backup format '/u01/app/oracle/duplicate/df_t%t_s%s_p%p ' database;
SQL ' alter system archive log current ';
Backup format '/u01/app/oracle/duplicate/al_t%t_s%s_p%p ' archivelog all delete input;
Release channel DUP;
} 3.4: Transferring Filestransfer the backed up backup set files to the/app/oracle/duplicate/of the replication library.
4. Copying a database The following operations are performed on the replication library Duplicate host.[email protected] duplicate]$rman target Sys/[email protected]_oracl--(here the Tar_oracl is connected to the target library of the Tnsname)rman>connect Auxiliary sys/[email protected]_oracl--(here the Dup_oracl is connected to the copy library of the Tnsname) rman>run{
Duplicate target database to Oraclbak Nofilenamecheck
LogFile Group 1 ('/u01/app/oracle/oradata/oracl/redo1_1.log ', '/u01/app/oracle/oradata/oracl/redo1_2.log ') size 512M ,
Group 2 ('/u01/app/oracle/oradata/oracl/redo2_1.log ', '/u01/app/oracle/oradata/oracl/redo2_2.log ') size 512M,
Group 3 ('/u01/app/oracle/oradata/oracl/redo3_1.log ', '/u01/app/oracle/oradata/oracl/redo3_2.log ') size 512M;
}--Nofilenamecheck is used here because of the consistency of the file directories of the copy library and the target library. starting Duplicate Db at 13-feb-12
Using target database control file instead of recovery catalog
Allocated Channel:ora_aux_disk_1
Channel ora_aux_disk_1:sid=156 Devtype=disk

Contents of Memory Script:
{
Set until SCN 1556049;
Set newname for DataFile 1 to
"/U01/APP/ORACLE/ORADATA/ORACL/SYSTEM01.DBF";
Set newname for DataFile 2 to
"/U01/APP/ORACLE/ORADATA/ORACL/UNDOTBS01.DBF";
Set newname for DataFile 3 to
"/U01/APP/ORACLE/ORADATA/ORACL/SYSAUX01.DBF";
Set newname for DataFile 4 to
"/U01/APP/ORACLE/ORADATA/ORACL/USERS01.DBF";
Set newname for DataFile 5 to
"/U01/APP/ORACLE/ORADATA/ORACL/HXL01.DBF";
Restore
Check ReadOnly
Clone database
;
}
Executing Memory Script

Executing command:set until clause

Executing Command:set NEWNAME

Executing Command:set NEWNAME

Executing Command:set NEWNAME

Executing Command:set NEWNAME

Executing Command:set NEWNAME

Starting restore at 13-feb-12
Using channel Ora_aux_disk_1

Channel ora_aux_disk_1:starting datafile backupset restore
Channel ora_aux_disk_1:specifying DataFile (s) to the restore from backup set
restoring DataFile 00001 to/u01/app/oracle/oradata/oracl/system01.dbf
restoring DataFile 00002 to/u01/app/oracle/oradata/oracl/undotbs01.dbf
restoring DataFile 00003 to/u01/app/oracle/oradata/oracl/sysaux01.dbf
restoring datafile 00004 to/u01/app/oracle/oradata/oracl/users01.dbf
restoring DataFile 00005 to/u01/app/oracle/oradata/oracl/hxl01.dbf
Channel ora_aux_disk_1:reading from backup Piece/u01/app/oracle/duplicate/df_t775114282_s89_p1
Channel ora_aux_disk_1:restored backup Piece 1
Piece HANDLE=/U01/APP/ORACLE/DUPLICATE/DF_T775114282_S89_P1 tag=tag20120213t053120
Channel Ora_aux_disk_1:restore complete, elapsed time:00:00:47
Finished restore at 13-feb-12
SQL Statement:create controlfile reuse SET DATABASE "Oracl" Resetlogs ARCHIVELOG
Maxlogfiles 16
Maxlogmembers 3
Maxdatafiles 100
Maxinstances 8
Maxloghistory 292
LOGFILE
GROUP 1 ('/u01/app/oracle/oradata/oracl/redo1_1.log ', '/u01/app/oracle/oradata/oracl/redo1_2.log ') SIZE M,
GROUP 2 ('/u01/app/oracle/oradata/oracl/redo2_1.log ', '/u01/app/oracle/oradata/oracl/redo2_2.log ') SIZE M,
GROUP 3 ('/u01/app/oracle/oradata/oracl/redo3_1.log ', '/u01/app/oracle/oradata/oracl/redo3_2.log ') SIZE M
DataFile
'/U01/APP/ORACLE/ORADATA/ORACL/SYSTEM01.DBF '
CHARACTER SET Al32utf8


Contents of Memory Script:
{
Switch clone datafile all;
}
Executing Memory Script

Released Channel:ora_aux_disk_1
DataFile 2 switched to datafile copy
Input datafile copy recid=1 stamp=775102986 filename=/u01/app/oracle/oradata/oracl/undotbs01.dbf
DataFile 3 switched to datafile copy
Input datafile copy recid=2 stamp=775102987 filename=/u01/app/oracle/oradata/oracl/sysaux01.dbf
DataFile 4 switched to datafile copy
Input datafile copy recid=3 stamp=775102987 filename=/u01/app/oracle/oradata/oracl/users01.dbf
DataFile 5 switched to datafile copy
Input datafile copy recid=4 stamp=775102987 filename=/u01/app/oracle/oradata/oracl/hxl01.dbf

Contents of Memory Script:
{
Set until SCN 1556049;
Recover
Clone database
Delete Archivelog
;
}
Executing Memory Script

Executing command:set until clause

Starting recover at 13-feb-12
Allocated Channel:ora_aux_disk_1
Channel ora_aux_disk_1:sid=156 Devtype=disk

Starting Media recovery

Channel ora_aux_disk_1:starting archive log restore to default destination
Channel ora_aux_disk_1:restoring Archive Log
Archive Log thread=1 sequence=47
Channel ora_aux_disk_1:restoring Archive Log
Archive Log thread=1 sequence=48
Channel ora_aux_disk_1:reading from backup Piece/u01/app/oracle/duplicate/al_t775114352_s91_p1
Channel ora_aux_disk_1:restored backup Piece 1
Piece HANDLE=/U01/APP/ORACLE/DUPLICATE/AL_T775114352_S91_P1 tag=tag20120213t053230
Channel Ora_aux_disk_1:restore complete, elapsed time:00:00:16
Archive Log Filename=/u01/app/oracle/flash_recovery_area/oracl/archivelog/2012_02_13/o1_mf_1_47_7mj0wydg_.arc Thread=1 sequence=47
Channel clone_default:deleting archive log (s)
Archive Log Filename=/u01/app/oracle/flash_recovery_area/oracl/archivelog/2012_02_13/o1_mf_1_47_7mj0wydg_.arc recid=2 stamp=775103016
Archive Log Filename=/u01/app/oracle/flash_recovery_area/oracl/archivelog/2012_02_13/o1_mf_1_48_7mj0x0qm_.arc Thread=1 sequence=48
Channel clone_default:deleting archive log (s)
Archive Log Filename=/u01/app/oracle/flash_recovery_area/oracl/archivelog/2012_02_13/o1_mf_1_48_7mj0x0qm_.arc Recid=1 stamp=775103009
Media recovery complete, elapsed time:00:00:09
Finished recover at 13-feb-12

Contents of Memory Script:
{
Shutdown clone;
Startup clone Nomount;
}
Executing Memory Script

Database dismounted
Oracle instance shut down

Connected to auxiliary database (not started)

Oracle instance started

Total System Global area 524288000 bytes

Fixed Size 1220360 bytes
Variable Size 138412280 bytes
Database buffers 381681664 bytes
Redo buffers 2973696 bytes
SQL Statement:create controlfile reuse SET DATABASE "Oracl" Resetlogs ARCHIVELOG
Maxlogfiles 16
Maxlogmembers 3
Maxdatafiles 100
Maxinstances 8
Maxloghistory 292
LOGFILE
GROUP 1 ('/u01/app/oracle/oradata/oracl/redo1_1.log ', '/u01/app/oracle/oradata/oracl/redo1_2.log ') SIZE M,
GROUP 2 ('/u01/app/oracle/oradata/oracl/redo2_1.log ', '/u01/app/oracle/oradata/oracl/redo2_2.log ') SIZE M,
GROUP 3 ('/u01/app/oracle/oradata/oracl/redo3_1.log ', '/u01/app/oracle/oradata/oracl/redo3_2.log ') SIZE M
DataFile
'/U01/APP/ORACLE/ORADATA/ORACL/SYSTEM01.DBF '
CHARACTER SET Al32utf8


Contents of Memory Script:
{
Set newname for Tempfile 1 to
"/U01/APP/ORACLE/ORADATA/ORACL/TEMP01.DBF";
Switch clone tempfile all;
Catalog Clone datafilecopy "/U01/APP/ORACLE/ORADATA/ORACL/UNDOTBS01.DBF";
Catalog Clone datafilecopy "/U01/APP/ORACLE/ORADATA/ORACL/SYSAUX01.DBF";
Catalog Clone datafilecopy "/U01/APP/ORACLE/ORADATA/ORACL/USERS01.DBF";
Catalog Clone datafilecopy "/U01/APP/ORACLE/ORADATA/ORACL/HXL01.DBF";
Switch clone datafile all;
}
Executing Memory Script

Executing Command:set NEWNAME

Renamed temporary file 1 to/u01/app/oracle/oradata/oracl/temp01.dbf in control file

Cataloged datafile Copy
DataFile Copy filename=/u01/app/oracle/oradata/oracl/undotbs01.dbf recid=1 stamp=775103080

Cataloged datafile Copy
DataFile Copy filename=/u01/app/oracle/oradata/oracl/sysaux01.dbf recid=2 stamp=775103081

Cataloged datafile Copy
DataFile Copy filename=/u01/app/oracle/oradata/oracl/users01.dbf recid=3 stamp=775103083

Cataloged datafile Copy
DataFile Copy filename=/u01/app/oracle/oradata/oracl/hxl01.dbf recid=4 stamp=775103084

DataFile 2 switched to datafile copy
Input datafile copy recid=1 stamp=775103080 filename=/u01/app/oracle/oradata/oracl/undotbs01.dbf
DataFile 3 switched to datafile copy
Input datafile copy recid=2 stamp=775103081 filename=/u01/app/oracle/oradata/oracl/sysaux01.dbf
DataFile 4 switched to datafile copy
Input datafile copy recid=3 stamp=775103083 filename=/u01/app/oracle/oradata/oracl/users01.dbf
DataFile 5 switched to datafile copy
Input datafile copy recid=4 stamp=775103084 filename=/u01/app/oracle/oradata/oracl/hxl01.dbf

Contents of Memory Script:
{
Alter Clone database open resetlogs;
}
Executing Memory Script

Database opened
Finished Duplicate Db at 13-feb-12

Small episode:
After the database opened using SYSDBA login prompt ora-01031:insufficient privileges, find a half-day reason is the password file naming problem, before creating the password file named Orapwdoraclbak, modify it to Orapworaclbak , problem solved, note that the name format of the password file under Linux is Orapw+sid.
Sql> Connect sys/[email protected]_oracl As SYSDBA
ERROR:
Ora-01031:insufficient PrivilegesFAQ:1. Unable to find an archive log when recoveringa specific archive log was not found during replication of the database recovery to report the following error:RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE, STACK follows ===============
RMAN-00571: ===========================================================
Rman-03002:failure of Duplicate Db command at 02/14/2012 01:01:41
Rman-03015:error occurred in stored script Memory script
Rman-06053:unable to perform media recovery because of missing log
Rman-06025:no Backup of Log thread 1 seq lowscn 1597845 found to restorethis time, you need to copy the archive log from the target library or use set until to specify a specific recovery to a sequence or SCN when copying, such as: run{
SET until sequence 52;
Duplicate target database to Oraclbak Nofilenamecheck
LogFile Group 1 ('/u01/app/oracle/oradata/oracl/redo1_1.log ', '/u01/app/oracle/oradata/oracl/redo1_2.log ') size 512M ,
Group 2 ('/u01/app/oracle/oradata/oracl/redo2_1.log ', '/u01/app/oracle/oradata/oracl/redo2_2.log ') size 512M,
Group 3 ('/u01/app/oracle/oradata/oracl/redo3_1.log ', '/u01/app/oracle/oradata/oracl/redo3_2.log ') size 512M;
}--the end--ext.: http://blog.chinaunix.net/uid-77311-id-3066925.html

To replicate a database using duplicate in Rman

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.