在 Debian 上测试 lsnrctl 的连通性,通常是指 Oracle Listener 是否正常运行、是否可连接。lsnrctl 是 Oracle 数据库监听器的管理工具,不是 Debian 自带软件,而是 Oracle 客户端或数据库软件的一部分。
下面分步说明如何测试。
which lsnrctl
或
ls $ORACLE_HOME/bin/lsnrctl
常见路径:
/u01/app/oracle/product/19.0.0/dbhome_1/bin/lsnrctl
如果找不到,说明:
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
(路径和 SID 按实际情况修改)
lsnrctl status
✅ 正常示例:
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
❌ 常见错误:
TNS-12541: TNS:no listenerTNS-12560: TNS:protocol adapter errorlsnrctl start
停止:
lsnrctl stop
ss -lntp | grep 1521
或
netstat -lntp | grep 1521
telnet localhost 1521
或
nc -vz localhost 1521
✅ 成功:
Connection to localhost 1521 port [tcp/*] succeeded!
tnsping ORCL
ORCL是tnsnames.ora中的服务名
✅ 正常:
OK (10 msec)
❌ 常见错误:
TNS-12541: no listenerTNS-12560TNS-03505: Failed to resolve namesqlplus system/password@localhost:1521/orcl
或
sqlplus system/password@orcl
✅ 能登录说明 Listener + 数据库都正常
iptables -L -n
或(新系统):
nft list ruleset
确保 1521 端口放行。
vi $ORACLE_HOME/network/admin/listener.ora
重点检查:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
echo $ORACLE_HOME
which lsnrctl
lsnrctl status
nc -vz localhost 1521
tnsping ORCL
sqlplus user/pass@orcl
如果你愿意,可以告诉我:
我可以帮你精确分析是哪一层的问题(网络 / listener / tns / 数据库)。