linux/unix平台如何查看OS上存在有哪些數據庫或實例
其實這是一個不難的問題,由於有同事問到這個問題,我就把這個問題的方法寫下來好了,必竟有一個人來問,說不定還有第二個人不會,希望對還不會的或是剛入行的朋友有所幫助吧。
linux/unix平台如何查看OS上存在多少個數據庫,查詢方法主要有三種,下面分別進行介紹
1、 通過lsnrctl status命令查看
通過該方法,可以查看已經注冊到listener中的數據庫實例,在一定程度可以說明OS上存在有命令結果中所列出來的數據庫實例,當然未啟動的和未注冊進來的除外
命令:#su – oracle
$lsnrctl status
[oracle@oraclelinux ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 04-AUG-2013 06:03:29
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.171.100)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 04-AUG-2013 05:57:12
Uptime 0 days 0 hr. 6 min. 17 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /dba/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /dba/oracle/diag/tnslsnr/oraclelinux/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.171.100)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "litest" has 1 instance(s).
Instance "litest", status READY, has 1 handler(s) for this service...
Service "litestXDB" has 1 instance(s).
Instance "litest", status READY, has 1 handler(s) for this service...
The command completed successfully
從上面表格結果集中,可以看到有一個 “litest”的數據庫實例注冊到了listener中來了,說明該OS上最少有一個名叫litest的數據庫實例存在
2、通過cat /etc/oratab方式查看
創建數據庫或實例時,會在/etc/oratab文件中增加一行記錄,哪怕是數據庫實例沒有啟動,用此方法也可以查看得到。如下所示:
命令:#cat /etc/oratab
[root@oraclelinux ~]# cat /etc/oratab
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
# Multiple entries with the same $ORACLE_SID are not allowed.
#
litest:/dba/oracle/product/11.2.0/db_1:N
從上面表格中最後一行結果中,可以看出該OS上存在有一個叫litest的數據庫(包括實例)
3、通過ps –ef |grep ora_pmon方式查看
如果數據庫或實例已經啟動至nomount模式,就會產生pmon進程,所以我們可以通過查看OS是否存在pmon進程的方式來查看有幾個數據庫實例存在,每一個實例都會有一個pmon進程,如果查到存在有多個pmon進程,就意味著OS上存在著多個數據庫實例
命令:# ps -ef |grep pmon
[root@oraclelinux ~]# ps -ef |grep pmon
oracle 3491 1 0 06:10 ? 00:00:00 ora_pmon_litest
root 3528 3459 0 06:11 pts/1 00:00:00 grep pmon
從上面表格中的結果中可以看到,OS上運行著一個名叫“litest”的數據庫實例