在 Debian 上,lsnrctl 是 Oracle Database 的监听控制工具,不是系统自带命令。要启动它,需要满足以下条件并按步骤操作。
已安装 Oracle Database(通常为企业版/XE)
lsnrctl 位于 Oracle 软件目录中,例如:$ORACLE_HOME/bin/lsnrctl
已配置 Oracle 环境变量
ORACLE_HOMEORACLE_SIDPATHsu - oracle
如果你不是用
oracle用户安装的,请切换到对应的 Oracle 安装用户。
export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
路径请根据你的实际安装情况修改。
source /u01/app/oracle/product/19.3.0/dbhome_1/bin/oracle_env.sh
或(老版本):
. /usr/local/bin/oraenv
lsnrctl start
如果成功,你会看到类似输出:
Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.3.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener is starting
lsnrctl status # 查看监听状态
lsnrctl stop # 停止监听
lsnrctl reload # 重新加载配置
lsnrctl: command not found原因:
解决:
echo $ORACLE_HOME
which lsnrctl
❌ 不可以
lsnrctl 是 Oracle 私有组件,只能通过安装 Oracle Database 获得。
Oracle XE 官方主要支持:
在 Debian 上安装 不推荐也不官方支持,通常建议:
ss -lntp | grep 1521
或
netstat -tulnp | grep 1521
如果你愿意,可以告诉我:
我可以给你更精确的启动方案。