28.4.3 检测Oracle数据库状态

28.4.3  检测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

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

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

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

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

                                                //监听程序的参数文件

Listener Parameter File   /u01/app/oracle/product/11.1.0/db_1/network/ad-
min/listener.ora

Listener Log File         /u01/app/oracle/product/11.1.0/db_1/log/diag/tn-
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

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

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

你可能感兴趣的:(Linux系统管理与网络管理)