在 Debian 系统中,你可以使用 lsnrctl 命令来查看监听端口。lsnrctl 是 Oracle 数据库监听器的控制工具,用于管理 Oracle 数据库监听器的启动、停止和查看监听器状态等操作。
以下是使用 lsnrctl 查看监听端口的方法:
lsnrctl首先,确保你已经安装了 Oracle 数据库软件,并且 lsnrctl 命令可用。通常情况下,Oracle 数据库软件会安装在 /opt/oracle/product/19c/dbhome_1/bin 目录下。
/opt/oracle/product/19c/dbhome_1/bin/lsnrctl start
启动 lsnrctl 后,你可以使用以下命令查看监听器的状态,包括监听的端口:
lsnrctl status
这个命令会显示监听器的详细信息,包括监听的地址和端口。例如:
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 12-JAN-2023 10:15:30
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 12-JAN-2023 10:10:30
Uptime 0 days 0 hr. 4 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/myhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhost.example.com)(PORT=1521)))
Services Summary...
Service "mydb" has 1 instance(s).
Instance "mydb", status READY, has 1 handler(s) for this service...
The command completed successfully
在这个例子中,监听器正在监听 1521 端口。
如果你有多个监听器,可以使用 lsnrctl services 命令查看每个监听器的详细信息,包括端口:
lsnrctl services
这个命令会列出所有监听器及其服务信息,包括每个服务的监听端口。
你也可以直接查看监听器的配置文件 listener.ora 来获取监听端口的详细信息。默认情况下,该文件位于 /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora。
cat /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
在 listener.ora 文件中,你可以找到类似以下的配置:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost.example.com)(PORT = 1521))
)
)
通过这些方法,你可以轻松地在 Debian 系统中使用 lsnrctl 查看 Oracle 数据库监听器的监听端口。