lsnrctl 是 Oracle 数据库的一个命令行工具,用于管理和监控 Oracle 数据库的监听器。要使用 lsnrctl 查看监听状态,请按照以下步骤操作:
打开命令行界面(在 Windows 上是命令提示符,Linux 和 macOS 上是终端)。
输入 lsnrctl status 命令,然后按 Enter 键。这将显示监听器的当前状态,包括监听器名称、版本、启动时间等信息。
示例输出:
Listening Parameter File: /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listening Log File: /u01/app/oracle/diag/tnslsnr/hostname/listener/alert/log.xml
Listening for incoming connections on [PROTOCOL:PORT]
若要查看特定监听器的详细信息,请使用 lsnrctl status [listener_name] 命令,其中 [listener_name] 是要查看的监听器的名称。如果未指定监听器名称,将显示默认监听器的状态。
示例输出:
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-JAN-2022 12:34:56
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 01-JAN-2022 12:30:00
Uptime 0 days 0 hr. 4 min. 56 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/hostname/listener/alert/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hostname)(PORT=1521)))
Service "CLRExtProc" 8000 52165 bequeathed no
Service "xe" 8000 52166 bequeathed no
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "clrextproc", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
Instance "XEPDB1", status READY, has 1 handler(s) for this service...
The command completed successfully
若要查看监听器正在监听的服务,请在 lsnrctl status 命令的输出中查找 “Services Summary” 部分。
请注意,您需要具有适当的权限才能运行 lsnrctl 命令。在某些系统上,您可能需要以 Oracle 用户身份登录或使用 sudo(在 Linux 和 macOS 上)或以管理员身份运行命令提示符(在 Windows 上)。