Heim > Datenbank > MySQL-Tutorial > Hauptteil

Oracle 11g DataGuard自动启动服务

WBOY
Freigeben: 2016-06-07 15:55:02
Original
1397 Leute haben es durchsucht

Oracle 11g DataGuard自动启动服务 只为了做的更好Just to do better script name:oracledg #!/bin/bash #chkconfig: 2345 98

Oracle 11g DataGuard自动启动服务

只为了做的更好
Just to do better

 script name:oracledg

 #!/bin/bash
 #chkconfig: 2345 98 01
 #description: Oracle database dataguard server
 #Starts the oracle database dataguard 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" > /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     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" > /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"  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

本文永久更新链接地址

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage