ALTER DATABASE ARCHIVELOG;
ALTER DATABASE FORCE LOGGING;
ALTER DATABASE ADD STANDBY LOGFILE ‘..’ SIZE 50M;
SELECT GROUP#, TYPE, MEMBER FROM V$LOGFILE WHERE TYPE = ‘STANDBY’;
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG = ‘DG_CONFIG=(db_unique_name_db, db_unique_name_sby)’;
SELECT * FROM V$DATAGUARD_CONFIG;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2=’SERVICE=stbydb, VALID_FOR=(ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME=db_unique_name_sby’;
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

#VALID_FOR = pairs of (logfiletype, role)
#log file types = ONLINE_LOGFILES / STANDBY_LOGFILES / ALL_LOGFILES
#role = PRIMARY_ROLE / STANDBY_ROLE / ALL_ROLES
#
# COMBINATION   PRIMARY  PHYSICAL LOGICAL
#ONLINE_LOGFILE, PRIMARY_ROLE Valid  Ignored  Ignored
#ONLINE_LOGFILE, STANDBY_ROLE…I….I…………V
#ONLINE_LOGFILE, ALL_ROLES ……..V….I…………V
#STANDBY_LOGFILE,STANDBY_ROLE I….V………..V
#STANDBY_LOGFILE,ALL_ROLES …….I….V………..V
#ALL_LOGFILES,PRIMARY_ROLE …….V….I…………I
#ALL_LOGFILES,STANDBY_ROLE …….I….V………..V
#ALL_LOGFILES,ALL_ROLES  …………V….V………..V
#
# n.b. both single and plural keywords are valid
#
# SYNC or ASYN, AFFIRN or NOAFFIRM
# ASYNC is default
# NOAFFIRM is default with ASYNC
# AFFIRM   is default with SYNC
#
# DB_FILE_NAME_CONVERT – do not use if OMF is in use.
# LOG_FILE_NAME_CONVERT – used to rename redo log file data – do not use if OMF is in use.
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;
#
COPY PRIMARY DB PASSWORD FILE TO THE STANDBY LOCATION.

CREATE AN INIT.ORA FILE CONTAINING JUST ONE LINE, “DB_NAME=stbyname”
CREATE THE AUDIT TRAIL IN $oracle_base/admin, i.e. $ORACLE_BASE/admin/dbname/adump
CREATE A DIRECTORY FOR THE ORACLE DATA FILES in $ORACLE_BASE/oradata
STARTUP STBY DB IN NOMOUNT
sql> startup nomount pfile=$initsby.ora;

ALTER SYSTEM SET FAL_CLIENT=’primary’;
ALTER SYSTEM SET FAL_SERVER=’stby’;

CREATE THE STANDBY
==================
$rman
rman> connect target sys/oracle
rman> connect auxiliary sys/oracle@pc00sby1
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 database
spfile
parameter_value_convert ‘pc00prmy’, ‘pc00sby1’
set db_unique_name=’pc00sby1′
set db_file_name_convert=’/pc00prmy/’,’/pc00sby1/’
set log_file_name_convert=’/pc00prmy/’,’/pc00sby1/’
set control_files=’/u01/app/oracle/oradata/pc00sby1.ctl’
set log_archive_max_processes=’5′
set fal_client=’pc00sby1′
set fal_server=’pc00prmy’
set standby_file_management=’AUTO’
set log_archive_config=’DG_CONFIG=(pc00prmy,pc00sby1)’
set log_archive_dest_1=’service=pc00prmy ASYNC valid_for=(onlibe_logfile, primary_role) db_unique_name=pc00prmy’;
}
rman> exit

The RECOVERY_MODE column of V$ARCHIVE_DEST_STATUS contains “MANAGED REAL TIME APPLY” when real-time apply is in use.
If you define a DELAY ON A DESTINATION AND USE REAL-TIME APPLY, the delay is ignored.

To start real-time apply use “ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

set DB_LOST_WRITE_PROTECT init parameter to detect lost writes.
TYPICAL (on primary) only read/write tablespaces
FULL    (on primary) r/w and readonly tablespaces
TYPICAL or FULL on standby, performs detection during mrp
NONE    disables LOST WRITE detection