Oracle 11g elastic uard automatic start service
Oracle 11g elastic uard automatic start service
Only for better performance
Just to do better
Script name: oracledg
#! /Bin/bash
# Chkconfig: 2345 98 01
# Description: Oracle database migration uard server
# Starts the oracle database extends uard server
# If more than four archive no application will be under the mout synchronization
# Make SHEEL: MUXINQNG
Case $1 in
'Start ')
If [! -F/var/lock/subsys/oracle]; then
Prog = "listener"
Echo-n $ "Starting $ prog :"
Su-oracle-c "lsnrctl start">/var/log/oracle. log
RETVAL =$?
[$ RETVAL-eq 0] & echo "success" | echo "failed"
Prog = "oracle dataguard"
Echo-n $ "Starting $ prog :"
Su-oracle-c "sqlplus/nolog" <EOF>/var/log/oracle. log
Connect/as sysdba
Startup mount
! Sleep 30
Select name, open_mode, PROTECTION_MODE, DATABASE_ROLE from v \ $ database;
Select thread #, min (sequence #) no_applied_min, max (sequence #) no_applied_max, count (1) no_applied_all from v \ $ archived_log where applied = 'no' and STANDBY_DEST = 'no' and deleted <> 'yes' group by thread # order by thread #;
Declare wyyn number;
Begin
Select count (1) into wyyn from v \ $ archived_log where applied = 'no' and standby_dest = 'no ';
If wyyn <5 then
Execute immediate 'alter database open ';
Execute immediate 'alter database recover managed standby database using current logfile disconnect ';
Else
Execute immediate 'alter database recover managed standby database using current logfile disconnect ';
End if;
End;
/
Select name, open_mode, PROTECTION_MODE, DATABASE_ROLE from v \ $ database;
Select applied, count (1) from v \ $ archived_log where applied = 'no' group by applied;
Exit
EOF
RETVAL =$?
[$ RETVAL-eq 0] & echo "success" | echo "failed"
Echo
[$ RETVAL-eq 0] & touch/var/lock/subsys/oracle | RETVAL = 1
Fi
;;
'Stop ')
Prog = "listener"
Echo-n $ "Stopping $ prog :"
Su-oracle-c "lsnrctl stop">/var/log/oracle. log
RETVAL =$?
[$ RETVAL-eq 0] & echo "success" | echo "failed"
Echo
Prog = "oracle dataguard"
Echo-n $ "Stopping $ prog :"
Su-oracle-c "sqlplus/nolog" <EOF>/var/log/oracle. log
Connect/as sysdba
Alter database recover managed standby database cancel;
Shutdown immediate
Exit
EOF
RETVAL =$?
[$ RETVAL-eq 0] & echo "success" | echo "failed"
Echo
[$ RETVAL-eq 0] & rm-f/var/lock/subsys/oracle
;;
'Restart ')
Prog = "oracle dataguard"
Echo-n $ "Stopping $ prog :"
$0 stop
Prog = "oracle dataguard"
Echo-n $ "Starting $ prog :"
$0 start
;;
'Status ')
Su-oracle-c "lsnrctl status"
Su-oracle-c "sqlplus/nolog" <EOF
Connect/as sysdba
Select name, open_mode, PROTECTION_MODE, DATABASE_ROLE from v \ $ database;
Select process, status from v \ $ managed_standby;
Exit
EOF
;;
*)
Echo $ "Usage: $0 {start | stop | restart | status }"
;;
Esac