[Shell] monitor oracle database listener & instance status
monitor oracle database listener & instance status
[mon@oracle source]$ crontab -l
* * * * * /home/mon/source/mon_db >> /home/mon/log/mon_db.log
[mon@oracle source]$ more mon_db
#!/bin/bash
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1
export ORACLE_SID=yangxu
datetime=`date +"%Y/%m/%d %H:%M:%S"`
hostname=`hostname`
lsnrstat=`ps -ef | grep -i tnslsnr | grep -v grep | wc -l`
if [ $lsnrstat -eq 0 ];then
echo "$datetime starting listener"
$ORACLE_HOME/bin/lsnrctl start
echo "$datetime start listener completed"
echo "$datetime $hostname started listener" | mutt -s "$datetime $hostname started listener" tolilong@163.com
else
echo "$datetime listener is already runing"
fi
dbstat=`ps -ef | grep -e ora_smon_$ORACLE_SID -e ora_pmon_$ORACLE_SID -e ora_lgwr_$ORACLE_SID | grep -v grep | wc -l`
if [ $dbstat -eq 0 ];then
echo "$datetime starting instance $ORACLE_SID"
$ORACLE_HOME/bin/sqlplus / nolog << EOF
conn / as sysdba;
startup;
EOF
echo "$datetime start instance complete"
echo "$datetime $hostname started database" | mutt -s "$datetime $hostname started database" tolilong@163.com
else
echo "$datetime $ORACLE_SID is already runing"
fi
[mon@oracle source]$ crontab -l
* * * * * /home/mon/source/mon_db >> /home/mon/log/mon_db.log
[mon@oracle source]$ more mon_db
#!/bin/bash
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/dbhome_1
export ORACLE_SID=yangxu
datetime=`date +"%Y/%m/%d %H:%M:%S"`
hostname=`hostname`
lsnrstat=`ps -ef | grep -i tnslsnr | grep -v grep | wc -l`
if [ $lsnrstat -eq 0 ];then
echo "$datetime starting listener"
$ORACLE_HOME/bin/lsnrctl start
echo "$datetime start listener completed"
echo "$datetime $hostname started listener" | mutt -s "$datetime $hostname started listener" tolilong@163.com
else
echo "$datetime listener is already runing"
fi
dbstat=`ps -ef | grep -e ora_smon_$ORACLE_SID -e ora_pmon_$ORACLE_SID -e ora_lgwr_$ORACLE_SID | grep -v grep | wc -l`
if [ $dbstat -eq 0 ];then
echo "$datetime starting instance $ORACLE_SID"
$ORACLE_HOME/bin/sqlplus / nolog << EOF
conn / as sysdba;
startup;
EOF
echo "$datetime start instance complete"
echo "$datetime $hostname started database" | mutt -s "$datetime $hostname started database" tolilong@163.com
else
echo "$datetime $ORACLE_SID is already runing"
fi
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2064890/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 19c Concepts(13):Oracle Database InstanceOracleDatabase
- 3.2.1 Mounting a Database to an InstanceDatabase
- Oracle Database Server 'TNS Listener'遠端資料投毒漏洞OracleDatabaseServer
- 3.1.5.2 Starting an Instance, and Mounting and Opening a DatabaseDatabase
- HowTo Restore RMAN Disk backups of RAC Database to Single Instance On Another NoRESTDatabase
- ORACLE database vaultOracleDatabase
- Oracle clone databaseOracleDatabase
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- Oracle OCP(43):listener.oraOracle
- Oracle listener log配置與管理Oracle
- oracle-listener 4GOracle
- Oracle 效能調優工具:SQL MonitorOracleSQL
- Oracle Database Scheduler整理OracleDatabase
- Oracle Physical Database LimitsOracleDatabaseMIT
- Oracle listener log 日誌分析方法Oracle
- Oracle 12.2 使用Database Link優化Standby Database WorkloadOracleDatabase優化
- ORACLE之手動註冊監聽listener。alter system set local_listener="XXX"Oracle
- Oracle SQL調優系列之SQL Monitor ReportOracleSQL
- Oracle 19c Concepts(01):Introduction to Oracle DatabaseOracleDatabase
- Oracle OCP(35):Database 安裝OracleDatabase
- oracle 10g flashback databaseOracle 10gDatabase
- Oracle DG Standby Database型別OracleDatabase型別
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- Oracle 12C Database File Mapping for Oracle ASM FilesOracleDatabaseAPPASM
- Oracle OCP(38):Database 物理結構OracleDatabase
- 關於Oracle Database Vault介紹OracleDatabase
- Scheduler in Oracle Database 10g(轉)OracleDatabase
- [翻譯]-Detect And Repair Corruption in an Oracle DatabaseAIOracleDatabase
- Oracle 19c Database Management ToolsOracleDatabase
- Oracle清理trace、alert、aud、listener.log檔案Oracle
- oracle 11g 【listener.ora tnsnames.ora】Oracle
- oracle清理trace、alert、aud、listener等日誌檔案Oracle
- Oracle 19c Concepts(00):Changes in This Release for Oracle Database ConceptsOracleDatabase
- 【Oracle】Windows安裝oracle11gR1 database 11.1.0.6OracleWindowsDatabase
- 【LISTENER】Oracle通過監聽連線緩慢分析Oracle
- Oracle OCP(37):Database 體系結構OracleDatabase
- Converting Oracle Database from Linux to Windows using RMANOracleDatabaseLinuxWindows
- Oracle database 升級(文件)to 10.2.0.4 from 10.2.0.1OracleDatabase