RMAN duplicate)

Source: Internet
Author: User

RMAN duplicate upgrades the versions of databases in the production environment or tests the performance and impact of new applications, backup and recovery, etc, we can clone it from the production environment to the local without affecting the normal use of the production database. We can use the rman duplicate Method and Its simple method to implement this function. The duplicate method is different from OS-level backup. It generates a new dbid for the secondary database (cloned database), and can simultaneously convert the target database (original database) register with the secondary database to the same recovery directory. This article describes how to use rman duplicate to clone a heterogeneous database. 1. the duplicate type supported by RMAN supports the backup-based duplicate method, which is divided into connecting to the target DB and not connecting to the target DB, if you do not connect to the target DB, you can connect to the catalog and do not connect to the catalog. The duplicate mode based on the active database is supported. You can use the following illustration to briefly describe the two methods. From Active DB -------------- | With recovery catalog connection Duplicate | snapshot ------------ | Without target conenction | percent | ---------------- | ------------- From Backups | Without recovery catalog connection | starts target connection 2 and RMAN recovery from different machines the following figure shows that the target DB is not connected, nor is it connected to the recover catalog method. To implement duplicate in this way, you should specify the location of the backup file. The experiment demonstrated below is also based on this method. During the demonstration, the disk path, directory, and data file use the same location and file name. 3. Actual RMAN clone

[SQL] -- Environment: -- target database: 192.168.7.25/Sybo/u01/database/Sybo Host Name: linux3 -- auxiliary database: 192.168.7.26/Sybo/u01/database/Sybo Host Name: linux4 the target database and the secondary database use the same file location -- Note: -- backup files are used in this demonstration, neither connected to catalog nor to target DB. [Oracle @ linux3 database] $ cat/etc/issue Enterprise Linux Server release 5.5 (Carthage) kernel \ r on an \ m SQL> select * from v $ version where rownum <2; BANNER login Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-Production a. Backup and ftp target Database -- tables and content in the target Database, used for subsequent verification of SQL> select * from t; name action ---------- -------------------- Robinson Transfer DB Jackson Transfer DB by rman -- back up the target database and ftp it to the host where the auxiliary database is located $ export ORACLE_SID = sybo3 $ rman target/RMAN> backup database include current controlfile plus archivelog delete input; $ scp-r fra 192.168.7.26:/u01/database/sybo3/--> if necessary, package the backup file. The fra directory here is the flashback zone -- Author: Robinson -- Blog: http://blog.csdn.net/robinson_0612 -- Ftp parameter file. If no pfile file exists, it can be generated from target db. Create pfile from spfile; $ scp $ ORACLE_HOME/dbs/initsybo3.ora 192.168.7.26: $ ORACLE_HOME/dbs B. create the corresponding dump folder [oracle @ linux4 database] $ more sybo3.sh #! /Bin/sh mkdir-p/u01/database mkdir-p/u01/database/sybo3/adump mkdir-p/u01/database/sybo3/controlf mkdir-p/u01/database /sybo3/fra mkdir-p/u01/database/sybo3/oradata mkdir-p/u01/database/sybo3/redo mkdir-p/u01/database/sybo3/dpdump mkdir-p /u01/database/sybo3/pfile [oracle @ linux4 database] $. /sybo3.sh c. Configure the auxiliary instance parameter file. Because auxiliary DB and target DB do not have file location conversion, no modifications are required. The following figure shows the parameter file copied from target DB to auxiliary [oracle @ linux4 ~] $ More/u01/oracle/db_1/dbs/initsybo3.ora sybo3. _ db_cache_size = 113246208 sybo3. _ java_pool_size = 4194304 sybo3. _ runtime = 4194304 sybo3. _ oracle_base = '/u01/oracle '# ORACLE_BASE set from environment sybo3. _ Sequence = 150994944 sybo3. _ sga_target = 226492416 sybo3. _ Sequence = 0 sybo3. _ shared_pool_size = 96468992 sybo3. _ streams_pool_size = 0 *. audit_file_dest = '/u01/database/sybo 3/adump /'*. audit_trail = 'db '*. compatible = '11. 2.0.0.0 '*. control_files = '/u01/database/sybo3/controlf/control01.ctl', '/u01/database/sybo3/controlf/control02.ctl '*. db_block_size = 8192 *. db_domain = 'orasrv. com '*. db_name = 'sybo3 '*. db_recovery_file_dest = '/u01/database/sybo3/fra '*. db_recovery_file_dest_size = 4039114752 *. dg_broker_config_file1 = '/u01/database/sybo3/db_broker/dr1sybo3. dat '*. dg_broker_con Fig_file2 = '/u01/database/sybo3/db_broker/dr2sybo3. dat '*. dg_broker_start = FALSE *. diagnostic_dest = '/u01/database/sybo3 '*. log_archive_dest_1 = ''*. memory_target = 374341632 *. open_cursors = 300 *. processes = 150 *. remote_login_passwordfile = 'clusive '*. undo_tablespace = 'undotbs1 'd. Generate the password file of the secondary instance. Use the orapwd command to complete $ orapwd file =/u01/oracle/db_1/dbs/orapwsybo3 password = oracle entries = 10 e, database cloning-no need to connect to t for this test Arget and catalog. Therefore, you can skip configuration listening and configure [oracle @ linux4 ~] After cloning. $ Export ORACLE_SID = sybo3 [oracle @ linux4 ~] $ Sqlplus/as sysdba SQL> startup nomount; --> Start the auxiliary instance to nomount [oracle @ linux4 ~] $ Rman auxiliary/--> connect directly to the secondary database connected to auxiliary database: SYBO3 (not mounted) RMAN> duplicate target database to Sybo spfile 2> backup location '/u01/database/Sybo/fra/Sybo' 3> nofilenamecheck; Starting Duplicate Db at 31-JUL-13 contents of Memory Script: {restore clone spfile to '/u01/oracle/db_1/dbs/spfilesybo3.ora' from ---> restore the spfile file from an automatic backup '/u01/database/sybo3/fra/SYB O3/autobackup/2013_07_31/o1_mf_s_822220850_8zjy9lp8 _. bkp '; SQL clone "alter system set spfile =''/u01/oracle/db_1/dbs/spfilesybo3.ora ''";} executing Memory Script Starting restore at 31-JUL-13 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID = 134 device type = DISK channel ORA_AUX_DISK_1: restoring spfile from AUTOBACKUP/u01/database/sybo3/fra/SYBO3/autobackup/2013_07_31/Snapshot 850_8zjy9lp8 _. bkp channel ORA_AUX_DISK_1: SPFILE restore from AUTOBACKUP complete Finished restore at 31-JUL-13 SQL statement: alter system set spfile = ''/u01/oracle/db_1/dbs/spfilesybo3.ora 'contents of Memory Script: {SQL clone "alter system set db_name = ---> modify spfile and restart the auxiliary instance ''sybo3' comment = ''duplicate'' scope = spfile"; shutdown clone immediate; startup clone nomount;} executing Memory Scri Pt SQL statement: alter system set db_name = 'symp3' 'comment = ''duplicate ''scope = spfile Oracle instance shut down connected to auxiliary database (not started) oracle instance started Total System Global Area 376635392 bytes Fixed Size 1336652 bytes Variable Size 285215412 bytes Database Buffers 83886080 bytes Redo Buffers 6197248 bytes contents of Memory Script: {SQL clone "alter system set d B _name = 'sybo3' 'comment = ''modified by RMAN duplicate ''scope = spfile "; SQL clone "alter system set db_unique_name = ''sybo3'' comment = ''modified by RMAN duplicate ''scope = spfile"; shutdown clone immediate; startup clone force nomount --> the following command is used to restore the control file restore clone primary controlfile from '/u01/database/sybo3/fra/SYBO3/autobackup/2013_07_31/o1_mf_s_822220850_8zjy9lp8 _. bkp '; alter clone databas E mount;} executing Memory Script SQL statement: alter system set db_name = ''sybo3 ''comment = ''modified by RMAN duplicate'' scope = spfile SQL statement: alter system set db_unique_name = ''symp3' comment = ''modified by RMAN duplicate ''scope = spfile Oracle instance shut down Oracle instance started Total System Global Area 376635392 bytes Fixed Size 1336652 bytes variable Size 285215412 bytes Da Tabase Buffers 83886080 bytes Redo Buffers 6197248 bytes Starting restore at specified allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID = 133 device type = DISK channel identifier: restoring control file channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 output file name =/u01/database/sybo3/controlf/control01.ctl output file name =/u01/database/sybo3/controlf/control02.ct L Finished restore at random database mounted released channel: ORA_AUX_DISK_1 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID = 133 device type = DISK RMAN-05538: WARNING: implicitly using limit contents of Memory Script: {set until scn 1177881; ---> set the time point to restore scn and modify datafile name. set newname for datafile 1 to "/u01/database/sybo3/oradata/system01.dbf"; set newname for dat Afile 2 to "/u01/database/sybo3/oradata/sysaux01.dbf"; set newname for datafile 3 to "/u01/database/sybo3/oradata/undotbs01.dbf "; set newname for datafile 4 to "/u01/database/sybo3/oradata/users01.dbf"; set newname for datafile 5 to "/u01/database/sybo3/oradata/example01.dbf "; restore ---> this command is used to restore the secondary database clone database;} executing Memory Script executing command: SET until clause executing command: Set newname executing command: set newname Starting restore at random using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore channel restart: specifying datafile (s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to/u01/database/syb O3/oradata/system01.dbf channel ORA_AUX_DISK_1: restoring datafile 00002 to/u01/database/sybo3/oradata/sysaux01.dbf channel ORA_AUX_DISK_1: restoring datafile 00003 to/u01/database/sybo3/oradata/undotbs01.dbf channel ORA_AUX_DISK_1: restoring datafile 00004 to/u01/database/sybo3/oradata/users01.dbf channel ORA_AUX_DISK_1: restoring datafile 00005 to/u01/database/sybo3/oradata/example01.dbf cha Nnel ORA_AUX_DISK_1: reading from backup piece/u01/database/sybo3/fra/SYBO3/backupset/2013_07_31/o1_mf_nnndf_TAG20130731T103921_8zjy6s8p _. bkp channel ORA_AUX_DISK_1: piece handle =/u01/database/sybo3/fra/SYBO3/backupset/2013_07_31/o1_mf_nnndf_TAG20130731T103921_8zjy6s8p _. bkp tag = TAG20130731T103921 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed tim E: 00:01:25 Finished restore at 31-JUL-13 contents of Memory Script: {switch clone datafile all; ---> Update Data file Information to control file} executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID = 1 STAMP = 822223969 file name =/u01/database/sybo3/oradata/ system01.dbf datafile 2 switched to datafile copy input datafile copy RECID = 2 STAMP = 822223969 file name =/u01/database/sybo3/oradata/sysaux0 1. dbf datafile 3 switched to datafile copy input datafile copy RECID = 3 STAMP = 822223969 file name =/u01/database/sybo3/oradata/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID = 4 STAMP = 822223969 file name =/u01/database/sybo3/oradata/users01.dbf datafile 5 switched to datafile copy input datafile copy RECID = 5 STAMP = 822223969 file name =/u01/database/ sybo3/oradata/example01.d Bf contents of Memory Script: {set until scn 1177881; recover ---> recover auxiliary database and delete log clone database delete archivelog;} executing Memory Script executing command: SET until clause Starting recover at 31-JUL-13 using channel ORA_AUX_DISK_1 starting media recovery channel ORA_AUX_DISK_1: starting archived log restore to default destination channel ORA_AUX_DISK_1: restoring archived log archived Log thread = 1 sequence = 41 channel ORA_AUX_DISK_1: reading from backup piece/u01/database/sybo3/fra/SYBO3/backupset/2013_07_31/sequence _. bkp channel ORA_AUX_DISK_1: piece handle =/u01/database/sybo3/fra/SYBO3/backupset/2013_07_31/o1_mf_annnn_TAG20130731T104049_8zjy9k8g _. bkp tag = TAG20130731T104049 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: r Estore complete, elapsed time: 00:00:01 archived log file name =/u01/database/sybo3/fra/SYBO3/archivelog/2013_07_31/o1_mf_1_41_8zk1c4xq _. arc thread = 1 sequence = 41 channel clone_default: deleting archived log (s) archived log file name =/u01/database/sybo3/fra/SYBO3/archivelog/2013_07_31/pai _. arc RECID = 1 STAMP = 822223972 media recovery complete, elapsed time: 00:00:01 Finished recover 31-JUL-13 contents of Memory Script: {shutdown clone immediate; ---> modify the startup clone nomount parameter; SQL clone "alter system set db_name = ''sybo3'' comment = ''reset to original value by RMAN ''scope = spfile "; SQL clone "alter system reset db_unique_name scope = spfile"; shutdown clone immediate; startup clone nomount;} executing Memory Script database dismounted Oracle instance shut down connected t O auxiliary database (not started) Oracle instance started Total System Global Area 376635392 bytes Fixed Size 1336652 bytes Variable Size 285215412 bytes Database Buffers 83886080 bytes Redo Buffers 6197248 bytes SQL statement: alter system set db_name = ''sybo3 ''comment = ''reset to original value by RMAN'' scope = spfile SQL statement: alter system Reset db_unique_name scope = spfile Oracle instanc E shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 376635392 bytes Fixed Size 1336652 bytes Variable Size 285215412 bytes Database Buffers 83886080 bytes Redo Buffers 6197248 bytes SQL statement: create controlfile reuse set database "SYBO3" resetlogs archivelog ---> recreate the control file and implicitly reset dbid MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 logfile group 1 SIZE 50 M, GROUP 2 SIZE 50 M, GROUP 3 SIZE 50 m datafile '/u01/database/sybo3/oradata/system01.dbf' character set AL32UTF8 contents of Memory Script: {set newname for tempfile 1 to "/u01/database/sybo3/oradata/temp01.dbf"; switch clone tempfile all; catalog clone datafilecopy "/u01/database/sybo3/oradata/sysaux01.dbf", "/u01/database/sybo3/oradata/undotbs01. Dbf ","/u01/database/sybo3/oradata/users01.dbf ","/u01/database/sybo3/oradata/example01.dbf "; switch clone datafile all ;} executing Memory Script executing command: set newname renamed tempfile 1 to/u01/database/sybo3/oradata/temp01.dbf in control file cataloged datafile copy file name =/u01/database/sybo3/oradata/sysaux01.dbf RECID = 1 STAMP = 822223994 cataloged datafile copy datafile Copy file name =/u01/database/sybo3/oradata/undotbs01.dbf RECID = 2 STAMP = 822223994 cataloged datafile copy file name =/u01/database/sybo3/oradata/users01.dbf RECID = 3 STAMP = 822223994 cataloged datafile copy file name =/u01/database/sybo3/oradata/example01.dbf RECID = 4 STAMP = 822223994 datafile 2 switched to datafile copy input datafile copy RECID = 1 STAMP = 822223994 file name =/ U01/database/sybo3/oradata/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID = 2 STAMP = 822223994 file name =/u01/database/sybo3/oradata/parse datafile 4 switched to datafile copy input datafile copy RECID = 3 STAMP = 822223994 file name =/u01/database/sybo3/oradata/users01.dbf datafile 5 switched to datafile copy input datafile copy RECID = 4 STAMP = 822223994 file name =/u01/ Database/sybo3/oradata/example01.dbf contents of Memory Script: {Alter clone database open resetlogs ;} executing Memory Script database opened Finished Duplicate Db at 31-JUL-13 -- for databases that are not connected to the target db or catalog and cloned using duplicate, you must specify the backup location. Otherwise, you will receive the following error message. -- This is because all backup-related information, including the backup location, is recorded in catalog or controlfile. However, when the duplicate command is released, the controlfile has not been restored yet. -- RMAN-05546: DUPLICATE without TARGET and CATALOG ons requires that backup location is specified f, verification results (create a listener as needed) [oracle @ linux4 ~] $ Sqlplus/as sysdba SQL> select instance_name, host_name from v $ instance; INSTANCE_NAME HOST_NAME ---------------- -------------------------------- Sybo linux4.orasrv.com SQL> select * from t; name action ---------- -------------------- Robinson Transfer DB Jackson Transfer DB by rman

 

4. Note a: When cloning an ECS instance from a different host, if aupoliciary DB uses the same disk configuration, directory structure, and file name as target DB, NOFILENAMECHECK must be specified. NOFILENAMECHECK can prevent you from checking whether the data files and online log files of target DB are in normal use. NOFILENAMECHECK should be avoided when the disk configuration, directory structure and file name of auxiliary DB and target DB are different. B. If the target DB or catalog is not connected, use BACKUP LOCATION '<bak_dir>' to specify the LOCATION of the BACKUP file.

Related Article

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.