发布于2026-07-04 阅读(0)
扫一扫,手机访问
在Oracle数据库的日常运维中,监听器连接测试是一项基础但至关重要的操作。通过lsnrctl这个命令行工具,你可以快速验证客户端与数据库之间的网络通路是否正常。下面就是具体的操作流程,跟着走一遍就能掌握。

首先,打开命令提示符(Windows)或终端(Linux/Unix)。
然后输入lsnrctl并按回车键,这会启动lsnrctl交互环境。
接着用status命令查看监听器的状态。这个命令会返回监听器的名称、版本、启动时间等关键信息,让你快速确认监听器是否在运行。例如:
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-JAN-2021 12:34:56
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 Date01-JAN-2021 12:34:56
Uptime0 days 0 hr. 30 min. 12 sec
Trace Level off
SecurityON: Local OS Authentication
SNMPOFF
Listener Parameter File /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/myhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhost.example.com)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "clrextproc", status READY, has 1 handler(s) for this service...
Service "mydb" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully确认监听器正常后,就可以用test命令来测试具体的连接了。你需要提供用户名、密码和连接描述符,格式如下:
lsnrctl test /@
其中连接描述符的写法是(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=。举个例子:
lsnrctl test scott/tiger@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost.example.com)(PORT=1521)))执行命令后,看看返回结果。如果连接成功,你会看到类似这样的消息:
TNS-12541: TNS:no listener
如果连接失败,则会显示错误信息,比如:
TNS-12560: TNS:protocol adapter error
TNS-00516: Lost connection
根据这些错误提示,你可以逐步排查网络、监听器配置或防火墙方面的问题。
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
8