Академический Документы
Профессиональный Документы
Культура Документы
1) Overview
A powerful feature of RMAN is the ability to duplicate (clone), a database from a backup. It is possible to create a duplicate database on: o o o A remote server with the same file structure A remote server with a different file structure The local server with a different file structure
A duplicate database is distinct from a standby database, although both types of databases are created with the DUPLICATE command. A standby database is a copy of the primary database that you can update continually or periodically by using archived logs from the primary database. If the primary database is damaged or destroyed, then you can perform failover to the standby database and effectively transform it into the new primary database. A duplicate database, on the other hand, cannot be used in this way: it is not intended for failover scenarios and does not support the various standby recovery and failover options. To prepare for database duplication, you must first create an auxiliary instance. For the duplication to work, you must connect RMAN to both the target (primary) database and an auxiliary instance started in NOMOUNT mode. So long as RMAN is able to connect to the primary and duplicate instances, the RMAN client can run on any machine. However, all backups, copies of datafiles, and archived logs used for creating and recovering the duplicate database must be accessible by the server session on the duplicate host. As part of the duplicating operation, RMAN manages the following: o Restores the target datafiles to the duplicate database and performs incomplete recovery by using all available backups and archived logs. Shuts down and starts the auxiliary database. Opens the duplicate database with the RESETLOGS option after incomplete recovery to create the online redo logs. Generates a new, unique DBID for the duplicate database.
o o
2) Preparing the Duplicate (Auxiliary) Instance for Duplication Create an Oracle Password File
First we must create a password file for the duplicate instance. export ORACLE_SID=APP2 orapwd file=orapwAPP2 password=manager entries=5 force=y
SQLNET.ORA NAMES.DIRECTORY_PATH= (TNSNAMES) NAMES.DEFAULT_DOMAIN = WORLD NAME.DEFAULT_ZONE = WORLD USE_DEDICATED_SERVER = ON Now restart the Listener lsnrctl stop lsnrctl start
### Global database name is db_name.db_domain ### ----------------------------------------db_name db_unique_name db_domain service_names instance_name ### Basic Configuration Parameters ### -----------------------------compatible db_block_size db_file_multiblock_read_count db_files control_files = = = = = 10.2.0.4 8192 32 512 /u01/oracle/db/APP2/con/APP2_con01.con, /opt/oracle/db/APP2/con/APP2_con02.con = = = = = APP2 APP2_GENTIC WORLD APP2 APP2
### Database Buffer Cache, I/O ### -------------------------# The Parameter SGA_TARGET enables Automatic Shared Memory Management sga_target sga_max_size = 500M = 600M
log_archive_max_processes log_archive_dest ### System Managed Undo ### ------------------undo_management undo_retention undo_tablespace ### Traces, Dumps and Passwordfile ### -----------------------------audit_file_dest user_dump_dest background_dump_dest core_dump_dest utl_file_dir remote_login_passwordfile
= 2 = /u01/oracle/db/APP2/arc
= = = = = =
crosscheck backup; list backup of database; report unrecoverable; report schema; report need backup; report obsolete; delete noprompt expired backup of delete noprompt expired backup of delete noprompt expired backup of delete noprompt obsolete recovery quit EOF
column member format a40 heading "Logfile" column group# format 99 heading "Group-Nr" select member, group# from v$logfile;
File-ID ------1 2 3 4
Logfile Group-Nr ---------------------------------------- -------/u01/oracle/db/APP1/rdo/APP1_log1A.rdo 1 /opt/oracle/db/APP1/rdo/APP1_log1B.rdo 1 /u01/oracle/db/APP1/rdo/APP1_log2A.rdo 2 /opt/oracle/db/APP1/rdo/APP1_log2B.rdo 2 /u01/oracle/db/APP1/rdo/APP1_log3A.rdo 3 /opt/oracle/db/APP1/rdo/APP1_log3B.rdo 3 /u01/oracle/db/APP1/rdo/APP1_log4A.rdo 4 /opt/oracle/db/APP1/rdo/APP1_log4B.rdo 4 /u01/oracle/db/APP1/rdo/APP1_log5A.rdo 5 /opt/oracle/db/APP1/rdo/APP1_log5B.rdo 5 /u01/oracle/db/APP1/rdo/APP1_log6A.rdo 6 /opt/oracle/db/APP1/rdo/APP1_log6B.rdo 6 /u01/oracle/db/APP1/rdo/APP1_log7A.rdo 7 /opt/oracle/db/APP1/rdo/APP1_log7B.rdo 7 /u01/oracle/db/APP1/rdo/APP1_log8A.rdo 8 /opt/oracle/db/APP1/rdo/APP1_log8B.rdo 8 /u01/oracle/db/APP1/rdo/APP1_log9A.rdo 9 /opt/oracle/db/APP1/rdo/APP1_log9B.rdo 9 /u01/oracle/db/APP1/rdo/APP1_log10A.rdo 10 /opt/oracle/db/APP1/rdo/APP1_log10B.rdo 10
sqlplus sys/manager as sysdba startup force nomount pfile='/home/oracle/config/10.2.0/initAPP2.ora'; exit; rman TARGET sys/manager@APP1 AUXILIARY sys/manager@APP2 Recovery Manager: Release 10.2.0.4.0 - Production on Tue Oct 28 12:00:13 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: APP1 (DBID=3191823649) connected to auxiliary database: APP2 (not mounted) RUN { SET NEWNAME FOR DATAFILE 1 TO '/u01/oracle/db/APP2/sys/APP2_sys1.dbf'; SET NEWNAME FOR DATAFILE 2 TO '/u01/oracle/db/APP2/sys/APP2_undo1.dbf'; SET NEWNAME FOR DATAFILE 3 TO '/u01/oracle/db/APP2/sys/APP2_sysaux1.dbf'; SET NEWNAME FOR DATAFILE 4 TO '/u01/oracle/db/APP2/usr/APP2_users1.dbf'; DUPLICATE TARGET DATABASE TO APP2 PFILE = /home/oracle/config/10.2.0/initAPP2.ora NOFILENAMECHECK LOGFILE GROUP 1 ('/u01/oracle/db/APP2/rdo/APP2_log1A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log1B.rdo') SIZE 10M REUSE, GROUP 2 ('/u01/oracle/db/APP2/rdo/APP2_log2A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log2B.rdo') SIZE 10M REUSE, GROUP 3 ('/u01/oracle/db/APP2/rdo/APP2_log3A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log3B.rdo') SIZE 10M REUSE, GROUP 4 ('/u01/oracle/db/APP2/rdo/APP2_log4A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log4B.rdo') SIZE 10M REUSE, GROUP 5 ('/u01/oracle/db/APP2/rdo/APP2_log5A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log5B.rdo') SIZE 10M REUSE, GROUP 6 ('/u01/oracle/db/APP2/rdo/APP2_log6A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log6B.rdo') SIZE 10M REUSE, GROUP 7 ('/u01/oracle/db/APP2/rdo/APP2_log7A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log7B.rdo') SIZE 10M REUSE, GROUP 8 ('/u01/oracle/db/APP2/rdo/APP2_log8A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log8B.rdo') SIZE 10M REUSE, GROUP 9 ('/u01/oracle/db/APP2/rdo/APP2_log9A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log9B.rdo') SIZE 10M REUSE, GROUP 10 ('/u01/oracle/db/APP2/rdo/APP2_log10A.rdo', '/opt/oracle/db/APP2/rdo/APP2_log10B.rdo') SIZE 10M REUSE; } The whole, long output is not shown here, but check, that RMAN was able to open the duplicate database with the RESETLOGS option. ..... ..... contents of Memory Script: { Alter clone database open resetlogs; } executing Memory Script database opened Finished Duplicate Db at 28-OCT-08
As the final step, eliminate or uncomment the DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT in the INIT.ORA file and restart the database. initAPP2.ora ### Duplicate Database ### ----------------------------------------------# This is only used when you duplicate the database # on the same host to avoid name conflicts # DB_FILE_NAME_CONVERT = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/) # LOG_FILE_NAME_CONVERT = (/u01/oracle/db/APP1/,/u01/oracle/db/APP2/, /opt/oracle/db/APP1/,/opt/oracle/db/APP2/) sqlplus / as sysdba shutdown immediate; startup; Total System Global Area 629145600 bytes Fixed Size 1269064 bytes Variable Size 251658936 bytes Database Buffers 373293056 bytes Redo Buffers 2924544 bytes Database mounted. Database opened.
cd /u01/backup scp gentic:/u01/backup/* . The other steps are the same as described under Creating a Duplicate Database on the Local Host.