檢測Oracle資料庫狀態

2021-09-26 14:00:33 字數 2965 閱讀 7215

檢測oracle資料庫狀態

oracle啟動後,為檢測oracle服務的執行是否正常,可以執行ps命令檢查相關的oracle服務程序,也可以通過oracle所提供的命令進行檢查。具體介紹如下所示。

(1)執行ps命令檢視資料庫程序情況。

ps -ef | grep oracle

(2)在sqlplus中執行命令檢視資料庫狀態。

$ export 

oracle_sid

=orcl

//設定oracle_sid環境變數

$ sqlplus /nolog //執行sqlplus命令

sql*plus: release 11.1.0.6.0 - production on wed oct 29 16:27:36 2008

sql>

conn sys@orcl as sysdba //連線資料庫

enter password:

connected.

sql>

select open_mode from v$database; //執行sql檢視資料庫的開啟方式

open_mode

----------

read write //"read write"表示資料庫狀態正常

如果連線資料庫時看到如下提示,那麼表示資料庫並未啟動。

sql>

conn sys as sysdba

enter password:

connected to an idle instance. //資料庫未啟動

(3)執行lsnrctl status命令檢視網路監聽程式的狀態,正常情況下應該能夠看到如下提示資訊。

$ lsnrctl status //檢視oracle監聽程式的狀態

lsnrctl for linux: version 11.1.0.6.0 - production on 29-oct-2008 16:35:11

connecting to (

description

=(address

=(protocol

=tcp

)(host

=demoserver

)(port

=1521

)))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

//監聽程式的引數檔案

min/listener.ora

slsnr/demoserver/listener/alert/log.xml //監聽程式的日誌檔案

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

如果監聽程式沒有啟動,那麼將返回如下錯誤資訊。

$ lsnrctl status //檢視oracle監聽程式的狀態

lsnrctl for linux: version 11.1.0.6.0 - production on 29-oct-2008 16:36:28

connecting to (

description

=(address

=(protocol

=tcp

)(host

=demoserver

)(port

=1521

)))tns-12541: tns:no listener //沒有發現監聽程式

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 //沒有發現監聽程式

tns-12560: tns:protocol adapter error

tns-00511: no listener

linux error: 2: no such file or directory

檢視Oracle資料庫狀態

show sga set wrap off set linesize 400 檢視正在執行的後台程序 select from v bgprocess select from v bgprocess where paddr 00 檢視資料庫的物理組成 檔案情況 select from v contro...

Oracle資料庫連線檢測(Shell)

oracle資料庫版本 oracle release 10.2.0.1.0 系統版本 red hat enterpriselinux 5.4 在有sqlplus執行許可權的使用者下,編輯check oracle connection.sh指令碼。vi check oracle connection....

資料庫狀態

查詢db狀態 select databasepropertyex adventureworks2016 status select state desc from sys.databases where name adventureworks2016 更改db狀態 alter database ad...