Oracle11gRMAN: ActiveDatabaseDuplicationforstandbydatabase
If the production-based duplicate replication is not manually configured with pfile (set memory, process, dg-related configuration parameters, database-related path parameters), various parameters cannot be converted;
Because duplicate will automatically copy pfile, control file, and password files from production. If the environment of the master database is different from that of the slave database (database software path and data file storage path)
If the path and conversion parameters of the new environment standby database are not completely specified in the duplicate command, the spfile parameter settings copied from the master database are used by default (oracle custom default configurations are ignored. For example, the default adr settings are placed under ORACLE_BASE, all parameter configurations are based on the spfile copied from the master database );
We do not recommend this configuration for those who are not particularly familiar with the original master database environment and oracle Database parameters!
------- Note that if = the backup database and the master database's $ ORACLE_BASE/$ ORACLE_HOME/Data Storage path are different, you must configure the following parameters:
run {allocate channel prmy1 type disk;allocate channel prmy2 type disk;allocate channel prmy3 type disk;allocate channel prmy4 type disk;allocate auxiliary channel stby type disk;duplicate target database for standby from active databasedorecoverspfileparameter_value_convert 'ora11g','lixora'set db_unique_name='orcl'set standby_file_management='AUTO'SET FAL_SERVER="ora11g"SET LOG_ARCHIVE_DEST_1='LOCATION=/oracle/app/oracle/oradata/arch VALID_FOR=(ALL_LOGFILE,ALL_ROLE) DB_UNIQUE_NAME=lixora'set log_archive_dest_2='service=ora11g ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=ora11g'SET CONTROL_FILES '/oracle/app/oracle/oradata/control01.ctl'set diagnostic_dest='/oracle/app/oracle'set audit_file_dest='/oracle/app/oracle'set DB_FILE_NAME_CONVERT='/u01/app/ora11/oradata/ORA11G/datafile/','/oracle/app/oracle/oradata/'SET LOG_FILE_NAME_CONVERT '/u01/app/ora11/oradata/ORA11G/onlinelog/', '/oracle/app/oracle/oradata/'set db_create_file_dest='/oracle/app/oracle/oradata/'set db_recovery_file_dest='/oracle/app/oracle/oradata/'#SET SGA_MAX_SIZE 200M#SET SGA_TARGET 185MNOFILENAMECHECK;}
Note the following storage directories: the flashback directory, the adr Directory, the audit log directory, and the Oracle-managed data file directory.
------------ Here I will explain the daily output after the above commands are executed to understand the principle of initializing the slave database using the above commands: $ rman target sys/sys @ chicago auxiliary sys/sys @ bostonconnected to target database: CHICAGO (DBID = 761464750) connected to auxiliary database: CHICAGO (not mounted) RMAN> run {allocate channel prmy1 type disk; allocate channel prmy2 type disk; allocate channel prmy3 type disk; allocate channel prmy4 type disk; allocate auxiliary channel stby type disk; duplicate target database for standby from active databasespfileparameter_value_convert 'Chicago ', 'boston' set db_unique_name = 'boston 'set db_file_name_convert = '/chicago /', '/boston/'set log_file_name_convert ='/chicago /', '/boston/'set control_files ='/u01/app/oracle/oradata/control01.ctl 'set log_archive_max_processes = '5' set fal_client = 'boston' set fal_server = 'Chicago 'set standby_file_management = 'auto' set log_archive_config = 'dg _ config = (chicago, boston) 'set log_archive_dest_2 = 'service = chicago ASYNCvalid_for = (ONLINE_LOGFILE, PRIMARY_ROLE) db_unique_name = chicago';} using target database control file instead of recovery catalogallocated channel: prmy1 --------- This is not to mention: distribution channel prmy1: SID = 147 device type = DISKallocated channel: prmy2channel prmy2: SID = 130 device type = DISKallocated channel: prmy3channel prmy3: SID = 137 device type = DISKallocated channel: prmy4channel prmy4: SID = 170 device type = DISKallocated channel: stbychannel stby: SID = 98 device type = DISKStarting Duplicate Db at 19-MAY-08contents of Memory Script: {backup as copy reuse ------------- copy the master database password file, spfile parameter file '/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore 'auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/ orapwcore1 'file'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore. ora 'auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora '; SQL clone "alter system set spfile =''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora ''";} executing Memory Script ---- Starting backup at 19-MAY-08Finished backup at 19-MAY-08sql statement: alter system set spfile = ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora'' ----- modify contents of Memory Script: ----------------------- here, according to the settings, some parameter settings marked in the spfile in the run script, RMAN will automatically generate the following script {SQL clone "alter system set audit_file_dest =''/u02/app/oracle/admin/boston/adump '''comment = ''' scope = spfile "; SQL clone "alter system set dispatchers ='' (PROTOCOL = TCP) (SERVICE = core1XDB) ''comment = ''' scope = spfile "; SQL clone "alter system set log_archive_dest_2 ='' service = core11 arch async VALID_FOR = (ONLINE_LOGFILES, PRIMARY_ROLE) db_unique_name = boston ''comment = ''' scope = spfile "; SQL clone "alter system set db_unique_name = ''boston'' comment = ''' scope = spfile "; SQL clone" alter system set db_file_name_convert = ''/chicago /'', ''/boston/'' comment = ''' scope = spfile "; SQL clone" alter system set log_file_name_convert = ''/chicago /'', '''/boston/''' comment = ''' scope = spfile "; SQL clone "alter system set control_files =''/u01/app/oracle/oradata/control01.ctl ''comment = ''' scope = spfile "; SQL clone "alter system set log_archive_max_processes = 5 comment = ''' scope = spfile "; SQL clone "alter system set fal_client = ''boston'' comment = ''' scope = spfile "; SQL clone "alter system set fal_server = ''chicago'' comment = ''' scope = spfile "; SQL clone "alter system set standby_file_management = ''auto'' comment = '''' scope = spfile "; SQL clone "alter system set log_archive_config ='' dg _ config = (chicago, boston) ''comment = ''' scope = spfile "; SQL clone "alter system set log_archive_dest_2 ='' service = chicago ASYNC valid_for = (ONLINE_LOGFILE, PRIMARY_ROLE) db_unique_name = chicago '''comment = ''' scope = spfile "; shutdown clone immediate; ---------------- when using this method to create a slave database, we only need to configure three parameters, including db_name, db_unique_name, and block_size, start the slave database to the nomount state. The main purpose is to allow rman to copy the spfile and password files of the master database.
Startup clone nomount;} executing Memory Scriptsql statement: alter system set audit_file_dest = ''/u02/app/oracle/admin/boston/adump'' comment = ''' scope = spfilesql statement: alter system set dispatchers = ''(PROTOCOL = TCP) (SERVICE = core1XDB)'' comment = ''' scope = spfilesql statement: alter system set log_archive_dest_2 = ''service = core11 arch async VALID_FOR = (ONLINE_LOGFILES, PRIMARY_ROLE) db_unique_name = boston '''comment = ''' scope = spfilesql statement: alter system set db_unique_name = ''boston ''comment = ''' scope = spfilesql statement: alter system set db_file_name_convert =''/chicago /'', ''/boston/'' comment = ''' scope = spfilesql statement: alter system set log_file_name_convert = ''/chicago /'', '''/boston/''' comment = ''' scope = spfilesql statement: alter system set control_files = ''/u01/app/oracle/oradata/control01.ctl'' comment = ''' scope = spfilesql statement: alter system set log_archive_max_processes = 5 comment = ''' scope = spfilesql statement: alter system set fal_client = ''boston ''comment = ''' scope = spfilesql statement: alter system set fal_server = ''chicago ''comment = ''' scope = spfilesql statement: alter system set standby_file_management = ''auto'' comment = ''' scope = spfilesql statement: alter system set log_archive_config = ''dg _ config = (chicago, boston) ''comment = ''' scope = spfilesql statement: alter system set log_archive_dest_2 = ''service = chicago ASYNC valid_for = (ONLINE_LOGFILE, PRIMARY_ROLE) db_unique_name = chicago ''comment = ''' scope = spfileOracle instance shut down ------------ restart here to use the updated spfileconnected to auxiliary database (not started) oracle instance startedTotal System Global Area 845348864 bytesFixed Size 1303188 bytesVariable Size 482348396 bytesDatabase Buffers 356515840 bytesRedo Buffers 5181440 bytescontents of Memory Script: ------------- Start copying the standby control file, and upload it to the corresponding location of the standby database {backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/control01.ctl '; SQL clone 'alter database mount standby database';} executing Memory ScriptStarting backup at 19-MAY-08channel prmy1: starting datafile copycopying standby control fileoutput file name =/u02/app/oracle/product/11.1.0/db_1/dbs/snapcf_chicago.f tag = TAG20080519T173406 RECID = 2 STAMP = 655148053 channel prmy1: datafile copy complete, elapsed time: 00: 00: 03 Finished backup at 19-MAY-08sql statement: alter database mount standby database -------------------- mount the standby database and prepare to modify the initialized data file path, and copy it to the standby database contents of Memory Script: {set newname for tempfile 1 to "/u02/app/oracle/oradata/boston/temp01.dbf"; switch clone tempfile all; set newname for datafile 1 to "/u02/app/oracle/oradata/boston/system01.dbf "; set newname for datafile 2 to "/u02/app/oracle/oradata/boston/sysaux01.dbf "; set newname for datafile 3 to "/u02/app/oracle/oradata/boston/undotbs01.dbf "; set newname for datafile 4 to "/u02/app/oracle/oradata/boston/users01.dbf "; backup as copy reusedatafile 1 auxiliary format "/u02/app/oracle/oradata/boston/system01.dbf" datafile 2 auxiliary format "/u02/app/oracle/oradata/boston/sysaux01.dbf" datafile 3 auxiliary format "/u02/app/oracle/oradata/boston/undotbs01.dbf" datafile 4 auxiliary format "/u02/app/oracle/oradata/boston/users01.dbf "; SQL 'alter system archive log current';} executing Memory Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to/u02/app/oracle/oradata/boston/temp01.dbf in control fileexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 19-MAY-08channel prmy1: starting datafile copyinput datafile file number = 00001 name =/u02/app/oracle/oradata/chicago/system01.dbfchannel prmy2: starting datafile copyinput datafile file number = 00002 name =/u02/app/oracle/oradata/chicago/sysaux01.dbfchannel prmy3: starting datafile copyinput datafile file number = 00003 name =/u02/app/oracle/oradata/chicago/undotbs01.dbfchannel prmy4: starting datafile copyinput datafile file number = 00004 name =/u02/app/oracle/oradata/chicago/users01.dbfoutput file name =/u02/app/oracle/oradata/boston/undotbs01.dbf tag = Beijing RECID = 0 STAMP = 0 channel prmy3: datafile copy complete, elapsed time: 00: 00: 24 output file name =/u02/app/oracle/oradata/boston/users01.dbf tag = TAG20080519T173421 RECID = 0 STAMP = 0 channel prmy4: datafile copy complete, elapsed time: 00: 00: 16 output file name =/u02/app/oracle/oradata/boston/system01.dbf tag = TAG20080519T173421 RECID = 0 STAMP = 0 channel prmy1: datafile copy complete, elapsed time: 00: 02: 32 output file name =/u02/app/oracle/oradata/boston/sysaux01.dbf tag = TAG20080519T173421 RECID = 0 STAMP = 0 channel prmy2: datafile copy complete, elapsed time: 00: 02: 32 Finished backup at 19-MAY-08sql statement: alter system archive log currentcontents of Memory Script: {switch clone datafile all; --------- modify the standby control file, update the new data file path in the standby control file} executing Memory Scriptdatafile 1 switched to datafile copyinput datafile copy RECID = 2 STAMP = 655148231 file name =/u02/app/oracle/oradata/boston/ system01.dbfdatafile 2 switched to datafile copyinput datafile copy RECID = 3 STAMP = 655148231 file name =/u02/app/oracle/oradata/boston/Hangzhou 3 switched to datafile copyinput datafile copy RECID = 4 STAMP = 655148231 file name =/u02/app/oracle/oradata/boston/undotbs01.dbfdatafile 4 switched to datafile copyinput datafile copy RECID = 5 STAMP = 655148231 file name =/u02/app/oracle/ oradata/boston/users01.dbfFinished Duplicate Db at 19-MAY-08released channel: prmy1released channel: prmy2released channel: prmy3released channel: prmy4
The backup database environment has been fully initialized, eliminating the need to manually configure the pfile parameter file in the backup database and manually copy the password file to the backup database, create a standby control and copy it to the slave database, copy the data file and back it up to the slave database, and so on. But here we still have a question: How does oracle directly copy those password files and parameter files, control File, data file to slave database? Here, I guess some interfaces of rman are called. The straightforward point is the method used with the third-party Data Backup Software of nbu. Now oracle thinks these interfaces can be used as well, since the release of active-database duplicate in 11g (starting from 11.1.0.6), the official statement about this feature oracle is as follows:
Active database duplication copies the live target database over the network to the auxiliary destination and then creates the duplicate database.
The duplication work is performed med by an auxiliary channel. This channel corresponds to a server session on the auxiliary instance on the auxiliary host.
The following are the tasks that rman does during Basic Steps to ACTIVE database duplication:
As part of the duplicating operation, RMAN automates the following steps:
1. Creates a control file for the duplicate database
2. Restarts the auxiliary instance and mounts the duplicate control file
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs.
4. Opens the duplicate database with the RESETLOGS option