在 Debian 上,lsnrctl 是 Oracle Database(通常是 Oracle 监听器) 的命令行工具,不是系统自带命令。能否使用它,取决于你是否已经安装了 Oracle Database 或 Oracle Instant Client。
下面分情况说明如何查看 lsnrctl 状态。
lsnrctl 是否已安装which lsnrctl
或
lsnrctl
如果提示:
command not found
说明 未安装 Oracle 监听器组件。
通常 Oracle 安装在 oracle 用户下:
su - oracle
source ~/.bash_profile
或手动设置(示例):
export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
lsnrctl status
输出示例:
LSNRCTL for Linux: Version 19.0.0.0.0
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0
Start Date 01-OCT-2024 10:00:00
Uptime 1 days 2 hr. 30 min.
ss -lntp | grep 1521
或
netstat -lntp | grep 1521
ps -ef | grep tnslsnr
❌ Debian 自带 lsnrctl?
不会。它是 Oracle 专有工具。
❌ apt 安装 lsnrctl?
不存在这个包。
✅ 正确方式:
lsnrctl你需要:
$ORACLE_HOME/bin/lsnrctl 是否存在| 场景 | 操作 |
|---|---|
| 已安装 Oracle | su - oracle → lsnrctl status |
| 未安装 Oracle | 无法使用 lsnrctl |
| 只想确认端口 | `ss -lntp |
| 找不到命令 | 检查 ORACLE_HOME/bin |
如果你愿意,可以告诉我:
我可以一步步帮你排查 ✅