Oracle 11g elastic uard automatic start service

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.