? List the purpose of creating a replica database? Select a method for replicating a database? Copy a database using Rman? Copy a database using Rman backup? Replicate a database based on a running instance
- Using the replica database
? Use the replica database to perform the following tasks: – Test the backup and recovery process – test upgrade to a new version of the Oracle database
– Test the impact of application changes on database performance – recover objects by creating an export file and importing objects into the production database? Create Replica database: – Using Rman's Duplicate command – on the same host or on a different host – contains a subset of the same content or source as the source – for backup-based replication, which is performed through the secondary channel – for active database replication, which is performed through the target channel Using the replica database copy database is a copy of your target database, which has a new unique database identifier (DBID). Passrunning the replica database independently (without relying on the target database) can perform the following tasks:? Test the backup and recovery process.? Test upgrade to a new version of the Oracle database.
? Test the impact of application changes on database performance. Create an export file that contains the objects in the replica database and import those objects into the production database, recovering accidentally fromthe object that was deleted in the target database. Although you may find that flashback queries, flashback deletions, and flashback tables are used to restoreA simpler and faster solution for the object. Create replica database:? You can use the duplicate command of Rman to create a replica database on the same host or on a different host. The replica database can contain the same content as the source database or contain only a subset of the source database. ? The main work of replication isAuxiliary ChannelImplementation of the. For backup-based replication, these channels correspond to the target masterServer session on the secondary instance on the machine. ? For active database replication, theTarget ChannelPerforms the work of pushing a copy of a data file into a secondary instance.
- Choosing a Database Replication method
Select a method to replicate a database-always connect to a secondary instance: You can replicate the source database to a target database on the same computer or on another computer. Associated with the replica databaseA db instance is called a secondary instance. All replication methods need to be connected to the secondary instance. This chart shows the following dataLibrary Copy method:? Connect to the target instance and the secondary instance from the active database? From backup, connect to target instance and secondary instance? From a backup, connect to a secondary instance, do not connect to the target instance, but have a recovery directory connection? From backup, connect to secondary instance, do not connect to target instance and recover directory
? Use the network (no backup required)? Include Custom SPFile? Copy the active database through the Oracle Enterprise Manager or Rman command line by using the from active of the Oracle Enterprise Manager or Rman duplicate commandsDatabase clause, you can instruct the source database to copy the image copy and the archive log copy directly to the secondary instance. You do not need to use a backup for this operation. RMAN connects to the source DB instance as target and acts as a auxiliaryConnect to the secondary instance. Copy the database files from the source database to the target database or secondary instance through the network connection between the instances. RMANthe recovery is then completed and the database is opened using memory script (included only in memory).
- Replicating a database through a target connection
? Connect to the target database (source database)? Connect to a secondary instance? Optional, connect to the recovery directory (or use a target control file) to replicate the database through the target connection when you replicate a database through a target database connection, RMAN can control files from the target database or from the recovery directorymetadata about the backup. This diagram depicts the execution of a target connection through theBackup-based replication。 RMAN connects to the source DB instance and the secondaryinstance. In addition, RMAN can connect to the recovery catalog database (not shown in the figure). The destination host must haveaccess to the Rman backup required to create the replica database.
- replicating a database with a recovery directory but no target connection
? Connect to the recovery directory for backup metadata? Connection to the secondary instance, which must have an instance of the Rman backupaccess RightsReplicating a database without a target connection if you do not connect to the target database while the database is being replicated, but you have a recovery directory, Rman will use the recoveryto get metadata about the backup. This diagram describes backup-based replication without a target connection. RMAN connects to the recovery catalog DB instance and the secondaryhelp Examples. The target host must have access to the Rman backup required to create the replica database.
- Replicating a database without a recovery directory or destination connection
Connect to the secondary instance, which must have access to the backup location of the diskPermissionsReplicating a database without a recovery directory or destination connection if the database is replicated without a destination database connection and the directory is not recovered, Rman uses allthe backup location where the required backups and replicas reside. This diagram describes the execution of a database instance that is not connected to a target DB instance or a recovery directoryreplication of backups. The disk backup location that contains all the backups or replicas required for replication must be available to the target host.
- To create a backup-based replica database
1. Create an Oracle password file for the secondary instance. 2. Establish an Oracle Net connection to the secondary instance. 3. Create an initialization parameter file for the secondary instance. 4. Start the secondary instance in Nomount mode. 5. Mount or open the target database. 6. Make sure that the backup and archive redo log files are available. 7. Assign the auxiliary channel as needed. 8. Execute the duplicate command. It is important to understand the above basic steps and the Rman database replication process. If you are using the Oracle Enterprise Manager Interface, the wizard can help you perform most of the steps. If youto create a replica database using the command line interface, you need to perform these steps manually. You can also use the EM interface as a testor an example, and write your own database replication script based on the output log. The basic steps for creating a replica database are outlined in this example.
- To create an initialization parameter file for a secondary instance
Please specify the parameters as follows:? db_name– if the replica database and the target database are in the same Oracle home directory,their names must be different. – Use the same value in the duplicate command. The value specified by db_block_size– should be the same as the value set for the target database. To create an initialization parameter file for a secondary instance you must create a text initialization parameter file for the secondary instance. The text initialization parameter file resides on the host that must be used toThe host on which the Rman client that executes the duplicate command resides is the same host. Please note the requirements for each of the following parameters:? Db_name: If the target database and the replica database are in the same Oracle home directory, you mustthe db_name is set to a different name. If they are in a different Oracle home directory, you must ensure that the replicaThe database name differs from other names in its Oracle home directory. Make sure that when you execute the duplicate command ,the database name used is the same as the name set for this parameter. ? Db_block_size: The block size of the secondary database must match the block size of the target database. Secondary dataThe value specified in the library initialization parameter file must be the same as the value set in the target database initialization parameter file. AsThis parameter is not set in the initialization parameter file of the target database, in the secondary instance initialization parameter fileand do not set it. Also, be sure to verify the settings of all initialization parameters for the specified pathname. Make sure that the replica database host can beaccesses all the specified paths.
- Specify a new name for the destination
Available methods:? SET newname command? CONFIGURE auxname Command (deprecated for recovery set data file)? Specify Db_file_name_convert in the duplicate commandParametersSpecify a new name for the destination you can specify a new name for the data file by using the following methods:? Include the set NEWNAME for datafile command in the run block to specify a new name for the data file. Use the Configure Auxname command. CONFIGURE Auxname is set newname.an alternative approach. The difference is that after the first configuration of the secondary name, the other duplicate command reuses the configuredsettings. In contrast, the set NEWNAME must be re-emitted each time the duplicate command is executed. Note: For recovery set data files, replace configure Auxname with set NewName.? Specify the Db_file_name_convert parameter with the duplicate command.
- Using the SET NEWNAME clause
? The SET newname clause is used for the database or named table space in theThere are files that specify the default name format. ? The default name is used for duplicate, restore, and in the run blockswitch command. ? It allows you to set the file name with a single command without having to separateset each file name. SET NEWNAME forDATABASEto {new| ' Formatspec '}; Using the SET NEWNAME clause you can use set newname for all data files in the named Tablespace and for all data files in the databaseSpecifies the default name format. The order of precedence for the Set NEWNAME command is as follows: 1.SET NEWNAME for datafile and set NEWNAME for TEMPFILE2. SET NEWNAME for TABLESPACE3. SET NEWNAME for database example: run{SET NEWNAME for DATABASE to '/u01/app/oracle/oradata/dupldb/%b ';DUPLICATE TARGET DATABASE to Dupldblogfilegroup 1 ('/u01/app/oracle/oradata/dupldb/redo01a.log ', '/u01/app/oracle/ Oradata/dupldb/redo01b.log ') SIZE 50M reuse,group 2 ('/u01/app/oracle/oradata/dupldb/redo02a.log ', '/u01/app/oracle/ Oradata/dupldb/redo02b.log ') SIZE 50M reuse,group 3 ('/u01/app/oracle/oradata/dupldb/redo03a.log ', '/u01/app/oracle/ Oradata/dupldb/redo03b.log ') SIZE 50M reuse;}
- Substitution Variables for SET newname
When the substitution variable for set NEWNAME issues set NEWNAME for database or set NEWNAME for tablespace, you mustSpecify substitution variables in the to <filename> clause to avoid name collisions. Please specify at least the following substitution variablesOne of:%b,%f, and%u. %i and%n are optional variables.
- Specify parameters for file naming
or specify the following parameters to explicitly control the file naming of the secondary database:? Control_files? Db_file_name_convert? Log_file_name_convert
control_files= '/u01/app/oracle/oradata/aux/control01.ctl ',
'/u01/app/oracle/oradata/aux/control02.ctl ',
'/u01/app/oracle/oradata/aux/control03.ctl '
db_file_name_convert= '/u01/app/oracle/oradata/orcl ',
'/u01/app/oracle/oradata/aux '
log_file_name_convert= '/u01/app/oracle/oradata/orcl ',
'/u01/app/oracle/oradata/aux '
When you specify a parameter for file naming to execute the duplicate command, RMAN generates the name of the required database file. By beginning at the secondary instanceyou can control the naming of these files by specifying the following initialization parameters in the init parameter file:? Control_files: You can use this parameter to specify the name of the control file. If you do not use this parameter to set the nameOracle Server creates Oracle-managed control files in the default control target. For specific information,? Db_file_name_convert: This parameter specifies the data file name of the secondary database. Its format isDb_file_name_convert = ' string1 ', ' string2 ', where string1 is the targetthe schema of the database file name, string2 is the schema of the secondary database file name. You can also specifythe Db_file_name_convert parameter serves as an option for the duplicate Database command. ? Log_file_name_convert: This parameter specifies the redo log file name for the secondary database. MailerThe formula is Log_file_name_convert = ' string1 ', ' string2 ', where string1is the schema of the target database file name, string2 is the schema of the secondary database file name. You can also usethe logfile clause of the DUPLICATE Database command specifies the redo log file name. In addition to using initialization parameters to control file naming, you can rename the redo log file using the following methods:? Use the logfile clause of the duplicate command. Set initialization parameters for Oracle Managed Files: Db_create_file_dest,db_create_online_dest_n or Db_recovery_file_dest.
- Launching an instance in Nomount mode
? Start the secondary instance in Nomount mode. Create a server based on the text initialization parameter file used to launch the instanceparameter file (SPFILE).
sql> startup Nomount pfile= ' $HOME/auxinstance/initaux.ora '
ORACLE instance started.
Total System Global area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 92276304 bytes
Database buffers 188743680 bytes
Redo buffers 2973696 bytes
sql> Create SPFile
2 from pfile= ' $HOME/auxinstance/initaux.ora ';
File created.
After you launch an instance in Nomount mode to create a text initialization parameter file, you can start the secondary instance in Nomount mode by calling Sql*plus. When Sql*plus is called, a server parameter file (SPFILE) is created based on the text initialization parameter file. Can be inexecute create SPFILE before and after launching the instance. SPFile should be created in the default location, so that you do not need toThe pfile option is specified in the duplicate command. RMAN shuts down the secondary instance during the copy process and then re-New Start it. Therefore, if you do not use SPFile, you must specify the Pfile option.
- Make sure that backup and archive redo log files are available
? All target database data files must be accessible on the replica host.Backup. ? A backup can be a combination of a full backup and an incremental backup. Must have access to the archive required to recover the replica database on the replica hostredo the log file. ? The archive redo log file can be: – Backup on Media Manager – Image copy – The actual archive redo log file ensures that the backup and archive redo log files are available on the replica host and must have access to the backup required to restore the data files. You don't need a full database backup. RMAN can use a combination of full backups and incremental backups of a single data file during replication. In addition, you must have access to the archive redo logs required to restore the replica database to the desired point in time. These archives are heavilyThe log file can be a backup, an image copy, or an actual archive redo log. Backup or copy can be transferred to replica dataon the local disk of the library node, or in some way over the network through a network file system (NFS).
- assigning auxiliary channels
? The secondary channel specifies the connection between the Rman and the secondary DB instance. If automatic channels are not configured, assign secondary channels: – Connect to the target DB instance, secondary instance, and recovery when Rman is starteddirectory (if applicable). – Allocate at least one secondary channel in the run block. $ rman target Sys/[email protected] auxiliary sys/[email protected]rman> run{
ALLOCATE Auxiliary CHANNELAux1 DEVICE TYPE DISK; ALLOCATE Auxiliary CHANNEL aux2 DEVICE TYPE DISK, ....
DUPLICATE TARGET DATABASE to Auxdb; . . . assigning auxiliary channels If no automatic channels are configured, assign at least one secondary channel manually before issuing the duplicate command. The ALLOCATE Auxiliary Channel command must be in the same run block as the duplicate command. ALLOCATE the channel type specified in the Auxiliary channel command must be the same as the target database backupmatch the media. ? If the backup resides on the disk, you can allocate multiple channels to reduce the time it takes for the replication process to take. For tape backups, you can specify the number of channels that correspond to the number of available devices. The secondary instance must be started with the Nomount option, and the target database must already be mounted or opened.
- Understanding Rman Replication Operations
When you execute the duplicate command, RMAN performs the following actions: 1A. Create a server parameter file for the secondary instance (for the number of activitiesbase backups performed using the target connection), or:1B. Restoring from a backup (for standby databases and for non-target connections based onreplication of backups)2. Load the backup control file 3. For backup-based replication: Select to restore the data file to the secondaryBackup of the instance4. Restore the target data file to replica database 5. Use all available incremental backups and archive redo log files for completeFull Recovery6. Close the secondary instance and restart it in Nomount Mode 7. Create a new control file, and then control the file in the data file andStorage of new dbid8. Open Replica Database 9 with the Resetlogs option. To create an online redo log file for the replica database note: The database replication process attempts to continue from the point of failure when it is re-executed. When you understand that the Rman copy operation executes the duplicate command, Rman performs the actions listed in the example. 1A. RMAN will create a default server parameter file for the secondary instance if the following conditions are true:-replication does not involve a standby database. -Do not replicate server parameter files. -the secondary instance is not started with a server parameter file. 1B. RMAN Restore from backup-for standby and backup-based replication without a target connection, alwaysso. 2. RMAN mounts the restored or copied backup control files from the active database. 3. For backup-based replication: Rman uses the Rman repository selection to restore a data file to a secondaryBackup of the help instance. 4. RMAN restores and replicates copies of the data files. 5. RMAN uses incremental backup and archive redo log files to recover data files to a non-current point in time. RMANYou must perform a database point-in-time recovery, even if you do not provide explicit time points for replication. Because the source databaseThe online redo log files in are not backed up and cannot be applied to the replica database, so point-in-time recovery is required. The furthest recovery point for a replica database is the most recent redo log file that is archived by the source database. 6. RMAN shuts down the DB instance and restarts it in Nomount mode. 7. RMAN creates a new control file that is then created and stored in the data file of the replica databasethe new unique database identifier dbid. 8. RMAN opens the replica database with the Resetlogs option. 9. RMAN creates an online redo log file for the replica database. Note: If the duplicate database command fails, you can re-execute the duplicate database command,the replication process attempts to continue from the point of failure.
- Specify options for the duplicate command
You can specify the following options in the duplicate command: Specify options for the duplicate command to specify additional options as needed when executing the duplicate command. SKIP READONLY: Used to exclude read-only tablespace data files. SKIP tablespace: Used to exclude table spaces from the target database. The system table space cannot be excluded or containsThe table space for the restore segment or fallback segment. Tablespace: Used to include table spaces in the target database. Nofilenamecheck: Used to prevent Rman from checking whether the target database data file is associated with a replica that is in useThe database data file has the same name. When the data files and redo log files of the target and replica databases use the samename, you must specify this option. When a host that creates a replica database has the same disk as the target database hostThis option is typically used when placing, directory structures, and file names. If Nofilenamecheck is not specified in this case,RMAN will return an error. Open RESTRICTED: Used to automatically enable the RESTRICTED SESSION after the database is opened.
- Use other duplicate command options
The following additional options for the duplicate command are introduced in Oracle Database 11g Release 2 using the additional duplicate command option:? The Noredo:noredo option is used to signal to rman that it is not applied during the recovery phase of the copy operationRedo the log. This option should be specified when the database is in Noarchivelog mode at the time of the backup:or, the archive redo log file is not available during the copy operation. If you are currently in Archivelog modedatabase is being copied to a point in time when it is in Noarchivelog mode, using this option is veryappropriate. If you are performing a duplicate with no target and the database is in Noarchivelog mode, you mustUse this option to inform Rman of the database schema. If you are not connected to the target database, RMAN will notset mode. ? UNDO tablespace: During a non-overall database copy process, RMAN checks all the tables that were copiedspace to verify that there are no objects belonging to the SYS user. SYSTEM, Sysaux, and restore segment table spaces are not herewithin the scope of the check. However, if the target database is not open during replication and the recovery directory is not used,RMAN will not be able to get the name of the restore tablespace. So you must use the Undo tablespace option to providethe name of the Restore segment table space.
- Cloning a database with EM
Using the EM clone database you can also use Oracle Enterprise Manager (EM) to create a replica (clone) database. From the EM homepage, navigateto Data movement > Clone database (Movement > Clone databases). The screenshot will display the Clonedatabase:source Type (Clone database: Source type) page. You can choose from the following locations to perform the cloning operation:? Running instances: You can specify that a running instance is cloned. Staging Area: The specified disk area on the source host and destination host. Create and store a backup here, and then place itinto the target staging area and read the target host to create the cloned database. ? Existing backup: You can use this location if you have a backup that reflects the state of the database that you are cloning.
? List the purpose of creating a replica database? Select a method for replicating a database? Copy a database using Rman? Copy a database using Rman backup? Replicate a database based on a running instance
Source: http://blog.csdn.net/rlhua/article/details/13509067