檢測Oracle數據庫狀態(tài)
Oracle啟動后,為檢測Oracle服務的運行是否正常,可以執(zhí)行ps命令檢查相關的Oracle服務進程,也可以通過Oracle所提供的命令進行檢查。具體介紹如下所示。 (1)執(zhí)行ps命令查看數據庫進程情況。
ps -ef | grep oracle
(2)在sqlplus中執(zhí)行命令查看數據庫狀態(tài)。
$ export ORACLE_SID=orcl //設置ORACLE_SID環(huán)境變量 $ sqlplus /nolog //執(zhí)行sqlplus命令 SQL*Plus: Release 11.1.0.6.0 - Production on Wed Oct 29 16:27:36 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved. SQL> conn sys@orcl as sysdba //連接數據庫 Enter password: Connected. SQL> select open_mode from v$database; //執(zhí)行SQL查看數據庫的打開方式 OPEN_MODE ---------- READ WRITE //“READ WRITE”表示數據庫狀態(tài)正常
如果連接數據庫時看到如下提示,那么表示數據庫并未啟動。
SQL> conn sys as sysdba Enter password: Connected to an idle instance. //數據庫未啟動
(3)執(zhí)行lsnrctl status命令查看網絡監(jiān)聽程序的狀態(tài),正常情況下應該能夠看到如下提示信息。
$ lsnrctl status //查看oracle監(jiān)聽程序的狀態(tài) LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 29-OCT-2008 16:35:11 Copyright (c) 1991, 2007, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=demoserver)(PORT= STATUS of the LISTENER ------------------------ Alias LISTENER //名稱 Version TNSLSNR for Linux: Version 11.1.0.6.0 – Production //版本號 Start Date 29-OCT-2008 15:40:30 //啟動時間 Uptime 0 days 0 hr. 54 min. 41 sec //已經運行的時間 Trace Level off Security ON: Local OS Authentication SNMP OFF //監(jiān)聽程序的參數文件 Listener Parameter File /u01/app/oracle/product/11.1.0/db_1/network/ad- Listener Log File /u01/app/oracle/product/11.1.0/db_1/log/diag/tn- Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "orcl" has 1 instance(s). //orcl服務 Instance "orcl", status READY, has 1 handler(s) for this service... Service "orcl_XPT" has 1 instance(s). //orcl_XPT服務 Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
如果監(jiān)聽程序沒有啟動,那么將返回如下錯誤信息。
$ lsnrctl status //查看oracle監(jiān)聽程序的狀態(tài) LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 29-OCT-2008 16:36:28 Copyright (c) 1991, 2007, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=demoserver)(PORT= TNS-12541: TNS:no listener //沒有發(fā)現監(jiān)聽程序 TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 111: Connection refused Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) TNS-12541: TNS:no listener //沒有發(fā)現監(jiān)聽程序 TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 2: No such file or directory |
|