ORACLE 11G Datagurad自動啟動服務
只為了做的更好
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" << 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
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" << 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
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29734436/viewspace-1710646/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centos 自動啟動指令碼和自啟動服務CentOS指令碼
- Oracle 11g dg broker自動failoverOracleAI
- Ubuntu Server 24.04 自啟動服務UbuntuServer
- oracle 11g自動記憶體管理Oracle記憶體
- ORACLE 11G 維護視窗和自動維護任務Oracle
- Oracle RAC自啟動Oracle
- 3.1.3 關於資料庫服務自動啟動資料庫
- 11G oracle資料庫重新啟動crsOracle資料庫
- win10開啟自動更新服務設定方法 window10如何開啟自動更新服務Win10
- oracle 11g dg broker 開啟fast-start failover自動故障切換OracleASTAI
- Oracle 11g RAC自動打GI PSU補丁Oracle
- 在Linux中,如何管理服務的自啟動?Linux
- Linux MySQL 服務設定開機自啟動LinuxMySql
- Linux Redis 服務設定開機自啟動LinuxRedis
- oracle配置開機自啟動Oracle
- 4 配置Oracle資料庫自動啟動Oracle資料庫
- Ubuntu 伺服器採用Systemed管理Tomcat服務自動啟動Ubuntu伺服器Tomcat
- Caddy 服務-- 自動httpsHTTP
- gitblit 服務啟動不了Git
- linux 下啟動服務Linux
- python 啟動http服務PythonHTTP
- CentOS 7 - 配置服務實現開機自啟動CentOS
- Linux使用Ambari啟動服務啟動失敗Linux
- 【OEM】Oracle oem取消開機自動啟動(linux)OracleLinux
- Drive.ai計劃啟動自動駕駛網約車服務AI自動駕駛
- 如何檢測Windows服務停止後自動啟動?自動執行.bat批處理檔案?WindowsBAT
- oracle資料庫的啟動關閉與各種服務Oracle資料庫
- Delphi Debug時自動結束已開啟的服務
- SpringBoot Windows 自啟動 - 透過 Windows Service 服務實現Spring BootWindows
- 服務啟動一個程式
- dubbo服務啟動的方式
- DUBBO服務啟動過程
- 啟動與關閉服務
- 控制linux啟動的服務Linux
- mongodb服務在哪裡啟動?MongoDB
- 怎麼啟動postgresql服務SQL
- windows下啟動nacos服務Windows
- Nuxt動態ip啟動開發服務UX
- Oracle 11g RAC手動新增serviceOracle