【SHELL】Linux系統 Oracle例項監控、重啟 簡易Shell指令碼
Linux系統 Oracle例項監控、重啟 簡易Shell指令碼
實驗環境
Red Hat Linux Enterprise 5
Oracle Database 11g Enterprise 11.2.0.3.0 - 64bit
在Linux系統中,透過一個簡單的shell指令碼,監控Oracle例項。
新增到crontab計劃任務,定時執行,可以再資料庫例項異常關閉後及時啟動例項。
點選(此處)摺疊或開啟
-
#!/bin/bash
-
-
echo \"################################################################\"
-
echo \"## Oracle Instance Monitor/Restart Shell ##\"
-
echo \"## ##\"
-
echo \"## Created by: Lv Xinghao ##\"
-
echo \"## Email : lvxinghao@163.com ##\"
-
echo \"## Blog : http://blog.itpub.net/29475508/ ##\"
-
echo \"################################################################\"
-
-
let i_num=\"`cat /etc/oratab | egrep \":Y|:N\" | awk -F \":\" \'{ print $1 }\' | wc -l`\"
-
-
if [ $i_num -gt 0 ];then
-
echo \"----------------------------------------------\"
-
echo $i_num oracle instance installed in this system.
-
echo \"----------------------------------------------\"
-
cat /etc/oratab | egrep \":Y|:N\" | awk -F \":\" \'{ print $1 }\'
-
cat /etc/oratab | egrep \":Y|:N\" | awk -F \":\" \'{ print $1 }\' > instance_name
-
-
for i in `cat instance_name`
-
do
-
-
export ORACLE_SID=$i
-
-
let smon_num=\"`ps -ef | grep $i | grep smon | grep -v grep |wc -l`\"
-
-
if [ $smon_num -eq 1 ]; then
-
-
echo \"------------------------------------------------\"
-
echo Oracle instance $i is running
-
echo \"------------------------------------------------\"
-
sqlplus \'/as sysdba\' <<EOF
-
select instance_name,status from v\\$instance;
-
quit;
-
EOF
-
-
else
-
echo \"------------------------------------------------\"
-
echo start oracle instance $i :
-
echo \"------------------------------------------------\"
-
sqlplus \'/as sysdba\' <<EOF
-
startup;
-
select instance_name,status from v\\$instance;
-
quit;
-
EOF
-
-
fi
-
-
done
-
-
else
-
echo No oracle instance in this system or oracle instance not in /etc/
- fi
點選(此處)摺疊或開啟
-
[oracle@beijing ~]$ sh /u03/shell/startinstance.sh
-
################################################################
-
## Oracle Instance Monitor/Restart Shell ##
-
## ##
-
## Created by: Lv Xinghao ##
-
## Email : lvxinghao@163.com ##
-
## Blog : http://blog.itpub.net/29475508/ ##
-
################################################################
-
----------------------------------------------
-
2 oracle instance installed in this system.
-
----------------------------------------------
-
BJ
-
GZ
-
------------------------------------------------
-
start oracle instance BJ :
-
------------------------------------------------
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 24 11:47:50 2014
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
Connected to an idle instance.
-
-
idle>ORACLE instance started.
-
-
Total System Global Area 626327552 bytes
-
Fixed Size 2230952 bytes
-
Variable Size 373294424 bytes
-
Database Buffers 247463936 bytes
-
Redo Buffers 3338240 bytes
-
Database mounted.
-
Database opened.
-
idle>
-
INSTANCE_NAME STATUS
-
---------------- ------------
-
BJ OPEN
-
-
idle>Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
-
Oracle Database Vault and Real Application Testing options
-
------------------------------------------------
-
start oracle instance GZ :
-
------------------------------------------------
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 24 11:47:57 2014
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
Connected to an idle instance.
-
-
idle>ORACLE instance started.
-
-
Total System Global Area 521936896 bytes
-
Fixed Size 2229944 bytes
-
Variable Size 322963784 bytes
-
Database Buffers 192937984 bytes
-
Redo Buffers 3805184 bytes
-
Database mounted.
-
Database opened.
-
idle>
-
INSTANCE_NAME STATUS
-
---------------- ------------
-
GZ OPEN
-
-
idle>Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
-
Oracle Database Vault and Real Application Testing options
- [oracle@beijing ~]$
當Oracle例項已啟動時 執行指令碼
點選(此處)摺疊或開啟
-
[oracle@beijing ~]$ sh /u03/shell/startinstance.sh
-
################################################################
-
## Oracle Instance Monitor/Restart Shell ##
-
## ##
-
## Created by: Lv Xinghao ##
-
## Email : lvxinghao@163.com ##
-
## Blog : http://blog.itpub.net/29475508/ ##
-
################################################################
-
----------------------------------------------
-
2 oracle instance installed in this system.
-
----------------------------------------------
-
BJ
-
GZ
-
------------------------------------------------
-
Oracle instance BJ is running
-
------------------------------------------------
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 24 11:40:36 2014
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
-
Oracle Database Vault and Real Application Testing options
-
-
sys@DGDB>
-
INSTANCE_NAME STATUS
-
---------------- ------------
-
BJ OPEN
-
-
sys@DGDB>Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
-
Oracle Database Vault and Real Application Testing options
-
------------------------------------------------
-
Oracle instance GZ is running
-
------------------------------------------------
-
-
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 24 11:40:36 2014
-
-
Copyright (c) 1982, 2011, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
-
Oracle Database Vault and Real Application Testing options
-
-
sys@TESTDB>
-
INSTANCE_NAME STATUS
-
---------------- ------------
-
GZ OPEN
-
-
sys@TESTDB>Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
-
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
-
Oracle Database Vault and Real Application Testing options
- [oracle@beijing ~]$
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29475508/viewspace-1226511/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Shell 系統資訊監控指令碼指令碼
- AIX系統資源監控SHELL指令碼AI指令碼
- 監控系統使用情況shell指令碼指令碼
- 使用 Shell 指令碼監控 Linux 系統程式資源指令碼Linux
- oracle會話監控shell指令碼Oracle會話指令碼
- shell指令碼例項指令碼
- linux系統下重啟tomcat的shell指令碼LinuxTomcat指令碼
- 【shell】磁碟監控指令碼指令碼
- Linux系統配置檔案簡易shell備份指令碼Linux指令碼
- 透過shell指令碼監控oracle session指令碼OracleSession
- 通過shell指令碼監控oracle session指令碼OracleSession
- 利用 Shell 指令碼來監控 Linux 系統的記憶體指令碼Linux記憶體
- 監控linux系統的shellLinux
- shell指令碼例項(2)指令碼
- 監控Oracle資料庫的常用shell指令碼Oracle資料庫指令碼
- 使用Shell指令碼對Linux系統和程式資源進行監控指令碼Linux
- shell指令碼監控啟動停止weblogic服務指令碼Web
- [轉]監控Oracle資料庫的常用shell指令碼Oracle資料庫指令碼
- 監控Oracle資料庫的常用shell指令碼(轉)Oracle資料庫指令碼
- 常用的主機監控shell指令碼指令碼
- 【轉載】監控Oracle資料庫的常用shell指令碼Oracle資料庫指令碼
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄 - 新增shell指令碼監控分散式指令碼
- shell指令碼:監控MySQL服務是否正常指令碼MySql
- 監控磁碟使用率的shell指令碼指令碼
- Shell指令碼監控MySQL主從狀態指令碼MySql
- 利用shell指令碼監控網站狀態指令碼網站
- 我常用的主機監控Shell指令碼指令碼
- 使用Linux系統的Shell指令碼維護Oracle(轉)Linux指令碼Oracle
- shell指令碼舉例指令碼
- shell實戰之Linux主機系統監控Linux
- 每5秒監控5000埠的shell指令碼指令碼
- shell指令碼:監控MySQL服務是否正常薦指令碼MySql
- Solaris linux 系統監控指令碼Linux指令碼
- LINUX Shell指令碼程式設計例項詳解(一)上Linux指令碼程式設計
- Linux Shell指令碼Linux指令碼
- Linux shell 指令碼Linux指令碼
- shell 指令碼注意事項指令碼
- Bash Shell指令碼中的陣列使用例項指令碼陣列