状态Oracle 11查看监听状态一步一步来(oracle11查看监听)
Oracle 11g是一款非常受欢迎的数据库管理系统,它的稳定性和灵活性得到了广泛的认可。在经常使用Oracle 11g的过程中,我们经常需要查看各种状态信息,其中包括监听状态。本文将介绍如何使用Oracle 11g来查看监听状态,通过一步一步的操作来帮助您更好地理解。
第一步:检查监听器是否存在
在开始查看监听状态之前,我们首先需要确定监听器是否已经在运行。可以使用以下命令来检查:
$ lsnrctl status
该命令会返回当前监听器的状态信息。如果监听器正在运行,您应该会看到一些有关监听器的信息,例如监听器地址、端口号和正在监听的协议,如下所示:
LSNRCTL for Linux: Version 11.2.0.1.0 – Production on 21-JAN-2022 01:42:15
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 – Production
Start Date 20-JAN-2022 08:16:11
Uptime 0 days 17 hr. 26 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/test/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “test” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
Service “testXDB” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
Service “test_XPT” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
The command completed successfully.
如果监听器没有运行,则会显示一条错误信息。在这种情况下,您需要启动监听器,可以使用以下命令:
$ lsnrctl start
完整的命令如下:
$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 – Production on 21-JAN-2022 01:42:15
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /opt/oracle/product/11.2.0/bin/tnslsnr: please wt…
TNSLSNR for Linux: Version 11.2.0.1.0 – Production
System parameter file is /opt/oracle/product/11.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/test/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 – Production
Start Date 21-JAN-2022 01:43:09
Uptime 0 days 0 hr. 0 min. 3 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/test/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary…
Service “test” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
Service “testXDB” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
Service “test_XPT” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
The command completed successfully.
第二步:查看监听器状态
启动监听器之后,我们就可以使用以下命令来查看监听器状态:
$ lsnrctl status
该命令会返回监听器的状态信息,包括监听器的地址、端口号和正在监听的协议。您还可以看到各种服务的状态信息,如下所示:
LSNRCTL for Linux: Version 11.2.0.1.0 – Production on 21-JAN-2022 01:44:07
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 – Production
Start Date 20-JAN-2022 08:16:11
Uptime 0 days 18 hr. 27 min. 56 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/test/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary…
Service “test” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
Service “testXDB” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
Service “test_XPT” has 1 instance(s).
Instance “test”, status READY, has 1 handler(s) for this service…
The command completed successfully.
在上面的示例中,我们可以看到一个名为“test”的服务及其相关实例的状态信息。如果您有多个服务或实例,则会在列表中看到相应数量的条目。
第三步:查看监听器日志
在使用监听器时,有时需要查看日志以获得更多信息。您可以使用以下命令来查看监听器日志:
$ tl -f $ORACLE_BASE/diag/tnslsnr/$HOSTNAME/listener/trace/listener.log
这个命令会持续输出最新的日志信息。您可以使用Ctrl+C来停止该命令。
总结
在Oracle 11g中查看监听状态非常简单。只需要使用一些基本的命令就能够轻松地获取监听器的状态信息和日志。如果您经常使用Oracle 11g,则可以将这些命令记住,以便在需要时随时使用。