A Physical Standby Exists
Data Guard Broker is configured and enabled (and using Oracle Wallet)
Commands below will be executed from the Primary database environment
EMAGENT_HOME is set in the 'oracle' .profile
dgmgrl /@ORCL1
CONVERT DATABASE ORCL2 TO SNAPSHOT STANDBY;
SHOW CONFIGURATION;
dgmgrl /@ORCL1
CONVERT DATABASE ORCL2 TO PHYSICAL STANDBY;
SHOW CONFIGURATION;
SHOW DATABASE ORCL2;
chown oracle:oinstall /u01/dba/auto/scripts/oradgbsnapstandb.sh
chmod 700 /u01/dba/auto/scripts/oradgbsnapstandb.sh
To check if the automated Snapshot Standby functionality is already scheduled, run this (as 'oracle') on the Primary and all Standby database servers..
crontab -l | grep oradgbsnapstandb.sh
To schedule, add something like this in the 'oracle' crontab... where ORCL1 is your Primary and ORCL2 is your Physical Standby...
The script can be scheduled on either server, but should not be scheduled on both.
For consistency it is recommended to schedule the script on the Server that is normally the Physical Standby.
The script should normally appear twice in the crontab: once as oradgbsnapstandb.ksh 1 to enable the snapshot standby and once as oradgbsnapstandb.ksh 0 to disable the snapshot standby (convert back to Physical Standby).
The example above opens the Snapshot Standby at 09:00 and reverts to Physical Standby at 16:00 each weekday (i.e. excludes Saturday and Sunday).
You can initiate the script from the command line as 'oracle' for ad-hoc Snapshot Standby invocation...
PRIMARY=ORCL1
STANDBY=ORCL2
WAIT=3600
/u01/dba/auto/scripts/oradgbsnapstandb.sh 1 ${PRIMARY} ${STANDBY}
/u01/dba/auto/scripts/oradgbsnapstandb.sh 0 ${PRIMARY} ${STANDBY} ${WAIT}
/u01/dba/auto/scripts/oradgbsnapstandb.sh s ${PRIMARY} ${STANDBY}
Arguments: 1 = Enable, 0 = Disable, s = Status report
The script automatically starts and ends a blackout. You do not need to do this is a separate task.
WAIT specifies the seconds to wait for the Standby to get back in sync before ending blackout (default 3600).
After running the script to disable the Snapshot Standby, you may want to run this script to report downtime.
/u01/dba/auto/scripts/oradbdowntimerep.sh
When the SYS password changes you should do this...
for SID in ${DGSID[@]}do mkstore -wrl ${WALLPATH} -modifyCredential ${SID} SYS dgm="'show database ${SID} StaticConnectIdentifier'" crd=$(echo ${dgm} | xargs dgmgrl -silent /@${SID} | tail -1 | awk '{ print substr($3,2,length($3)-2) }' ) mkstore -wrl ${WALLPATH} -modifyCredential ${crd} SYSdoneYou will be prompted for the SYS password and the Wallet password for each entry
mkdir -p /u01/dba/auto/scripts
mkdir -p /u01/dba/auto/logs
SQLNET.ORA must contain this stanza...
(assuming your Oracle Wallet is in /home/oracle/wallet)WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = /home/oracle/wallet) ) )SQLNET.WALLET_OVERRIDE = TRUETNSNAMES.ORA must contain entries for the Primary and Standby databases...
LISTENER.ORA must contain this stanza on the Primary...
(SID_DESC = (GLOBAL_DBNAME = ORCL1_DGMGRL.mydomain) (ORACLE_HOME = /u01/app/oracle/product/121020ORCL1) (SID_NAME = ORCL1) )..and this stanza on the Standby...
(SID_DESC = (GLOBAL_DBNAME = ORCL2_DGMGRL.mydomain) (ORACLE_HOME = /u01/app/oracle/product/121020ORCL2) (SID_NAME = ORCL2) )These stanzas go in the SID_LIST section under SID_LIST_LISTENER. For a full example see the LISTENER.ORA page.To troubleshoot the automated Snapshot Standby script, review the logs in /u01/dba/auto/logs and the alert.log of both database instances.
Log in /u01/dba/auto/logs shows...
------------------------------------------------------Converting to Physical Standby------------------------------------------------------Converting database "orcl2" to a Physical Standby database, please wait...Operation requires shutdown of instance "ORCL2" on database "atlas"Shutting down instance "ORCL2"...ORA-01013: user requested cancel of current operationAlert log for ORCL2 shows...
Tue Oct 25 17:01:08 2022Active call for process 42205378 user 'oracle' program 'oracle@myhost'SHUTDOWN: Active sessions prevent database close operation Shutdown did not complete in 60 minutesInstance shutdown cancelledTo fix, on the Standby...
Ensure WALLPATH is set to the correct Wallet.
Ensure TNS_ADMIN points to the correct TNS location (if you are not using the default)
sqlplus / as sysdba
shutdown immediate
startup mount
exit
dgmgrl /@ORCL1
CONVERT DATABASE ORCL2 TO PHYSICAL STANDBY;
exit
This will again prompt to shutdown/startup mount.
sqlplus / as sysdba
shutdown immediate
startup mount
exit
Wait for database apply lag to decrease to 0.
Start by attempting to invoke Snapshot Standby manually using debug mode...
dgmgrl -debug /@${ORACLE_SID}
Confirm that the connections exactly match the entries in the Wallet