Enable archiving and forced logging on the primary database.
SQL> archive log list SQL>alter database force logging; SQL>select name,log_mode,force_logging from gv$database; NAME LOG_MODE FOR --------- ------------ --- COCO ARCHIVELOG YES COCO ARCHIVELOG YES
Set all necessary initialization parameters on the primary database.
Verify that the values are set correctly for these parameters after bouncing the database.
SQL>set linesize 500 pages 0 col valuefor a90 col name for a50 select name, value from v$parameter where name in ('db_name','db_unique_name','log_archive_config', 'log_archive_dest_1','log_archive_dest_2', 'log_archive_dest_state_1','log_archive_dest_state_2', 'remote_login_passwordfile', 'log_archive_format','log_archive_max_processes','fal_server','fal_client', 'db_file_name_convert','log_file_name_convert', 'standby_file_management');
DB_FILE_NAME_CONVERT is useful for creating a duplicate database for recovery purposes. It converts the filename of a new datafile on the primary database to a filename on the standby database. LOG_FILE_NAME_CONVERT converts the filename of a new log file on the primary database to the filename of a log file on the standby database.
Start the standby database instance without mounting the control file.
~]$ sqlplus / as sysdba SQL> startup nomount pfile='/tmp/pfile_for_stby.ora'
Creating a standby database with active database duplication.
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Feb 10 20:55:00 2024
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: COCO (DBID=3082357723) connected to auxiliary database: COCO (not mounted)
RMAN> duplicate target database for standby from active database nofilenamecheck;
Starting Duplicate Db at 10-FEB-24 using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=10 instance=coco1 device type=DISK
contents of Memory Script: { backup as copy reuse targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwcoco1' auxiliary format '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwcoco1' ; } executing Memory Script
Starting backup at 10-FEB-24 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=76 instance=coco1 device type=DISK Finished backup at 10-FEB-24
contents of Memory Script: { backup as copy current controlfile for standby auxiliary format '+DATA/coco/control01.ctl'; restore clone controlfile to '+DATA/coco/control02.ctl' from '+DATA/coco/control01.ctl'; } executing Memory Script
Starting backup at 10-FEB-24 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy copying standby control file output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_coco1.f tag=TAG20240210T205515 RECID=4 STAMP=1160600119 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 Finished backup at 10-FEB-24
Starting restore at 10-FEB-24 using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: copied control file copy Finished restore at 10-FEB-24
contents of Memory Script: { sql clone'alter database mount standby database'; } executing Memory Script
sql statement: alter database mount standby database
contents of Memory Script: { set newname for tempfile 1 to "+DATA/coco/temp01.dbf"; switch clone tempfile all; set newname for datafile 1 to "+DATA/coco/system01.dbf"; set newname for datafile 2 to "+DATA/coco/sysaux01.dbf"; set newname for datafile 3 to "+DATA/coco/undotbs01.dbf"; set newname for datafile 4 to "+DATA/coco/users01.dbf"; set newname for datafile 5 to "+DATA/coco/undotbs02.dbf"; backup as copy reuse datafile 1 auxiliary format "+DATA/coco/system01.dbf" datafile 2 auxiliary format "+DATA/coco/sysaux01.dbf" datafile 3 auxiliary format "+DATA/coco/undotbs01.dbf" datafile 4 auxiliary format "+DATA/coco/users01.dbf" datafile 5 auxiliary format "+DATA/coco/undotbs02.dbf" ; sql 'alter system archive log current'; } executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to +DATA/coco/temp01.dbf in control file
datafile 1 switched to datafile copy input datafile copy RECID=4 STAMP=1160600191 file name=+DATA/coco/system01.dbf datafile 2 switched to datafile copy input datafile copy RECID=5 STAMP=1160600191 file name=+DATA/coco/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID=6 STAMP=1160600191 file name=+DATA/coco/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID=7 STAMP=1160600191 file name=+DATA/coco/users01.dbf datafile 5 switched to datafile copy input datafile copy RECID=8 STAMP=1160600191 file name=+DATA/coco/undotbs02.dbf Finished Duplicate Db at 10-FEB-24
In addition, copy the server parameter file from the source database to the duplicate database by specifying the SPFILE statement.
RMAN> duplicate target database for standby from active database spfile set db_unique_name='cocostby' set control_files='+data/coco/control01.ctl','+reco/coco/control02.ctl' set fal_server='coco' set fal_client='cocostby' set remote_listener='newrac-scan:1521' set standby_file_management='auto' reset log_archive_dest_2 reset log_archive_dest_state_2 nofilenamecheck;
Create standby online redo log on the standby database, standby redo log must have at least one more redo log group than the redo log at the redo source database.
SQL>set lines 200 col memberfor a50 select l.group#,l.thread#,l.status,l.bytes/1024/1024 "SIZE(M)",lf.member,lf.status from v$log l leftjoin v$logfile lf on l.group#=lf.group# orderby1;
SQL>select a.thread, a.received, b.applied from (select thread# thread, max(sequence#) received from v$archived_log groupby thread#) a, (select thread# thread, max(sequence#) applied from v$log_history groupby thread#) b where a.thread = b.thread orderby1;
Add a standby database configuration to cluster database configuration.
SQL> alter database recover managed standby database cancel;
SQL> alter database recover managed standby database using current logfile disconnect;
SQL> select inst_id, name, database_role, open_mode from gv$database;
INST_ID NAME DATABASE_ROLE OPEN_MODE ---------- --------- ---------------- -------------------- 1 COCO PHYSICAL STANDBY READ ONLY WITH APPLY 2 COCO PHYSICAL STANDBY READ ONLY WITH APPLY