温馨提示×

如何安装ubuntu lsnrctl

小樊
44
2026-10-08 06:43:30
栏目: 智能运维

在 Ubuntu 上,lsnrctl 并不是 Linux 自带命令,它是 Oracle Database(特别是 Oracle 监听器 Listener) 的一部分,属于 Oracle Instant Client 或 Oracle Database 软件。

下面按常见情况说明如何“安装/获得 lsnrctl”。


一、重要说明(先看清)

✅ lsnrctl 只存在于 Oracle 环境中
❌ 不能通过 apt install lsnrctl 安装
❌ 不属于 MySQL / PostgreSQL / 系统服务

如果你只是想:

  • 查看端口监听 → 用 netstat / ss
  • 管理 Oracle 数据库 → 才需要 lsnrctl

二、方式一:安装 Oracle Instant Client(最轻量)

⚠️ Instant Client 本身不包含 lsnrctl
✅ 但 Oracle Database 才包含

如果你只是连接 Oracle,不需要 lsnrctl。


三、方式二:安装 Oracle Database(才有 lsnrctl)

1️⃣ 安装 Oracle Database(示例:Oracle XE)

sudo apt update
sudo apt install -y alien bc libaio1

下载 Oracle XE(如 21c / 18c / 11g):

wget https://download.oracle.com/otn-pub/linux/instant/client/...

(Oracle 官方需登录下载)

安装后:

sudo /etc/init.d/oracle-xe-21c configure

2️⃣ 配置环境变量

export ORACLE_HOME=/opt/oracle/product/21c/dbhomeXE
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=XE

生效:

source ~/.bashrc

3️⃣ 验证 lsnrctl

lsnrctl status

输出示例:

LSNRCTL for Linux: Version 21.0.0.0.0
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER

✅ 成功


四、方式三:从 Oracle 客户端管理员处获取

如果你是:

  • DBA
  • 运维
  • 使用公司 Oracle 服务器

通常只需:

scp user@oracle-server:/u01/app/oracle/product/21c/dbhome_1/bin/lsnrctl ~/

但 单独复制通常不可用(依赖 Oracle 库)


五、常见问题

❓ lsnrctl command not found

说明:

  • Oracle 未安装
  • PATH 未配置

❓ Ubuntu 能直接装 lsnrctl 吗?

❌ 不能,必须装 Oracle


六、总结

需求 正确做法
安装 lsnrctl 安装 Oracle Database
只连 Oracle 用 Instant Client
看监听端口 ss -tulnp

如果你能告诉我:

  • Ubuntu 版本
  • Oracle 版本(XE / 19c / 21c)
  • 是本地装还是远程用

我可以给你 一步一步精确命令。

0 踩