Observer plays critical role during automatic failover, but sometimes routine maintenance would restart the Linux instance running observer and causes observer in stopped after instance reboot. Here are scripts to start observer automatically during Linux OS startup.
Running observer in background requires Oracle wallet setup, refer to below 2 links for more details:
- https://docs.oracle.com/en/database/oracle/oracle-database/19/dbseg/configuring-authentication.html#GUID-3EA07020-A9F3-4FF9-9518-E1AEA3BDDBBE
- https://docs.oracle.com/en/database/oracle/oracle-database/19/dgbkr/examples-using-data-guard-broker-DGMGRL-utility.html#GUID-AAE5EA1A-53A2-4D8D-BF59-A2856B38C99D
/home/oracle/start_observer.sh
#!/bin/bash
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/client
export LD_LIBRARY_PATH=/u01/lib
export PATH=/u01/sqlcl/bin:$ORACLE_HOME/bin:$PATH
ObserverRunning=`ps -ef|grep dgmgrl|grep -v grep|wc -l`
# echo $ObserverRunning
if [[ $ObserverRunning -eq 1 ]]
then
echo "Observer is already running"
else
dgmgrl <<EOD
start observer in background logfile is '/tmp/observer.log' connect identifier is rds_custom_orcl_a;
EOD
fi
/etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
su - oracle -c "nohup /home/oracle/start_observer.sh &"
Make sure change these scripts to be *executable".
chmod +x /home/oracle/start_observer.sh
chmod +x /etc/rc.local