oracledba.help
Scripts

PostCR.sql

<- Scripts

-- PostCR.sql
-- @/tmp/PostCR.sql
-- Purpose: Run after dbca createDuplicateDB -createAsStandby executed.
set verify off


-- Confirm
prompt PostCR.sql 
prompt 1. Needs to run from Standby database as SYS user.
prompt 2. Ensure you can connect to Primary and SB from both systems.
prompt
show user
prompt
ACCEPT v_prompt PROMPT 'Press Enter to continue.'
prompt

-- SB Database Parameter Changes
prompt SB Database Parameter Changes...
alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORADB_SB' scope=spfile;
alter system set db_file_name_convert='/u01/oradata/ORADB', '/u01/oradata/ORADB_SB' scope=spfile;
alter system set log_file_name_convert='/u02/oradata/ORADB','/u02/oradata/ORADB_SB' scope=spfile;
alter system set standby_file_management=auto scope=spfile;

alter system set dg_broker_config_file1='/u01/oradata/ORADB_SB/dr1.dat' scope=spfile;
alter system set dg_broker_config_file2='/u02/oradata/ORADB_SB/dr2.dat' scope=spfile;

alter system set db_flashback_retention_target=120 scope=spfile;
alter database flashback on;
alter system set dg_broker_start=true scope=spfile;
alter system set remote_listener='ORADB:1521' scope=spfile;

ACCEPT v_prompt PROMPT 'About to bounce database - press Enter to continue.' 
shutdown immediate
startup
alter system register;


-- Primary Database Parameter Changes
connect sys/go@ORADB as sysdba
show user
ACCEPT v_prompt PROMPT 'Confirm connected to Primary as SYS - press Enter to continue.'

alter system set standby_file_management=auto scope=both;
alter system set dg_broker_config_file1='/u01/oradata/ORADBB/dr1.dat' scope=spfile;
alter system set dg_broker_config_file2='/u02/oradata/ORADBB/dr2.dat' scope=spfile;
alter system set dg_broker_start=TRUE;
PROMPT Sleeping 60 seconds...
host sleep 60

-- DGMGRL
ACCEPT v_prompt PROMPT 'About to run dgmgrl on Primary - press Enter to continue.'
prompt
host dgmgrl sys/go@ORADB "CREATE CONFIGURATION dgconfig AS PRIMARY DATABASE IS ORADB CONNECT IDENTIFIER IS ORADB";
PROMPT Sleeping 60 seconds...
host sleep 60

host dgmgrl sys/go@ORADB "ADD DATABASE ORADB_SB AS CONNECT IDENTIFIER IS ORADB_SB";
host dgmgrl sys/go@ORADB "ENABLE CONFIGURATION"


-- END
prompt
prompt *** Process Ended ***
prompt