阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

修改Oracle默认监听端口

400次阅读
没有评论

共计 8200 个字符,预计需要花费 21 分钟才能阅读完成。

我们都知道,Oracle 的监听默认端口是 1521,但是如果系统上 1521 已经被占用或业务要求不用默认端口,则需要修改监听的默认端口。
修改监听端口只需要修改配置文件 listiner.ora,然后重启监听就行了。但是 Oracle 实例的 PMON 进程还是会去找监听 1521 端口的监听进程去注册,所以同时也需要修改数据库的配置。数据库里只需要在线修改 LOCAL_LISTINER 即可。
下面以 11.2.0.4 为例测试修改监听端口:
1、修改监听端口
# 查看监听状态
[oracle@rhel6 ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:16:24
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
————————
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 11.2.0.4.0 – Production
Start Date                07-JAN-2017 20:16:16
Uptime                    0 days 0 hr. 0 min. 8 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Listener Log File        /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary…
Service “orcl” has 1 instance(s).
  Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully
# 停止监听
[oracle@rhel6 ~]$ lsnrctl stop
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:17:39
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The command completed successfully
# 修改配置文件 listener.ora,改监听端口为 2521
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))
      (ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
# 启动监听
[oracle@rhel6 ~]$ lsnrctl start
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:19:11
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Starting /u02/app/oracle/product/11.2.4/db1/bin/tnslsnr: please wait…
 
TNSLSNR for Linux: Version 11.2.0.4.0 – Production
System parameter file is /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Log messages written to /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
STATUS of the LISTENER
————————
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 11.2.0.4.0 – Production
Start Date                07-JAN-2017 20:19:11
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Listener Log File        /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
The listener supports no services
The command completed successfully

至此,监听端口已经修改完毕,这时 Oracle 实例是无法注册到此监听上的。
2、修改 LOCAL_LISTINER 参数
# 修改参数
sys@ORCL>alter system set local_listener=”(address = (protocol = tcp)(host = rhel6)(port = 2521))”;
 
System altered.
# 查看监听状态
[oracle@rhel6 ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:23:10
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
STATUS of the LISTENER
————————
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 11.2.0.4.0 – Production
Start Date                07-JAN-2017 20:19:11
Uptime                    0 days 0 hr. 3 min. 59 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Listener Log File        /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary…
Service “orcl” has 1 instance(s).
  Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully

修改完后,可以看到数据库实例立即注册到监听器上。
3、使用新端口进行测试连接
[c:\~]$ sqlplus zx/zx@192.168.56.2:2521/orcl
 
SQL*Plus: Release 12.1.0.1.0 Production on 星期六 1 月 7 20:24:17 2017
 
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
 
连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL>

修改监听端口完成。
4、把 Oracle 实例的注册端口改回 1521
sys@ORCL>alter system set local_listener=”;
 
System altered.

官方文档中还提供了另一种配置 LOCAL_LISTINER 的方法:
在 tnsnames.ora 中添加配置,然后配置 LOCAL_LISTINER 为 tnsnames.ora 中的名字即可
# 配置 tnsnames.ora
[oracle@rhel6 admin]$ vi tnsnames.ora 
listener1=(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.2)(PORT = 2521))
# 修改 LOCAL_LISTINER 参数
sys@ORCL>alter system set local_listener=listener1;
 
System altered.
# 查看监听状态
[oracle@rhel6 ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:34:01
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
STATUS of the LISTENER
————————
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 11.2.0.4.0 – Production
Start Date                07-JAN-2017 20:31:28
Uptime                    0 days 0 hr. 2 min. 33 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Listener Log File        /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary…
Service “orcl” has 1 instance(s).
  Instance “orcl”, status READY, has 1 handler(s) for this service…
The command completed successfully

另外还可以使用静态监听的方法来修改监听的端口,但是 Oracle 实例不是“主动”注册到监听器上的。
sys@ORCL>show parameter local_listener
 
NAME                    TYPE                VALUE
———————————— ——————————— ——————————
local_listener              string
# 修改监听为静态监听
[oracle@rhel6 admin]$ vi listener.ora
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521))
      (ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=orcl)
      (ORACLE_HOME=/u02/app/oracle/product/11.2.4/db1)
      (SID_NAME=orcl))
# 重启监听
[oracle@rhel6 ~]$ lsnrctl stop
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:38:45
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
The command completed successfully
[oracle@rhel6 ~]$ lsnrctl start
 
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 07-JAN-2017 20:38:51
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Starting /u02/app/oracle/product/11.2.4/db1/bin/tnslsnr: please wait…
 
TNSLSNR for Linux: Version 11.2.0.4.0 – Production
System parameter file is /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Log messages written to /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
STATUS of the LISTENER
————————
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 11.2.0.4.0 – Production
Start Date                07-JAN-2017 20:38:52
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u02/app/oracle/product/11.2.4/db1/network/admin/listener.ora
Listener Log File        /u02/app/oracle/diag/tnslsnr/rhel6/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=2521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary…
Service “orcl” has 1 instance(s).
  Instance “orcl”, status UNKNOWN, has 1 handler(s) for this service…
The command completed successfully

静态监听实例的状态为 UNKNOWN,测试连接成功
[c:\~]$ sqlplus zx/zx@192.168.56.2:2521/orcl
 
SQL*Plus: Release 12.1.0.1.0 Production on 星期六 1 月 7 20:40:03 2017
 
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
 
连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL>

更多 Oracle 相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-01/139420.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计8200字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19350
评论数
4
阅读量
7964903
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
告别Notion焦虑!这款全平台开源加密笔记神器,让你的隐私真正“上锁”

告别Notion焦虑!这款全平台开源加密笔记神器,让你的隐私真正“上锁”

  告别 Notion 焦虑!这款全平台开源加密笔记神器,让你的隐私真正“上锁” 引言 在数字笔记工...
你的云服务器到底有多强?宝塔跑分告诉你

你的云服务器到底有多强?宝塔跑分告诉你

你的云服务器到底有多强?宝塔跑分告诉你 为什么要用宝塔跑分? 宝塔跑分其实就是对 CPU、内存、磁盘、IO 做...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

4盘位、4K输出、J3455、遥控,NAS硬件入门性价比之王

  4 盘位、4K 输出、J3455、遥控,NAS 硬件入门性价比之王 开篇 在 NAS 市场中,威...
在Windows系统中通过VMware安装苹果macOS15

在Windows系统中通过VMware安装苹果macOS15

在 Windows 系统中通过 VMware 安装苹果 macOS15 许多开发者和爱好者希望在 Window...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
恶意团伙利用 PHP-FPM 未授权访问漏洞发起大规模攻击

恶意团伙利用 PHP-FPM 未授权访问漏洞发起大规模攻击

恶意团伙利用 PHP-FPM 未授权访问漏洞发起大规模攻击 PHP-FPM(FastCGl Process M...
每年0.99刀,拿下你的第一个顶级域名,详细注册使用

每年0.99刀,拿下你的第一个顶级域名,详细注册使用

每年 0.99 刀,拿下你的第一个顶级域名,详细注册使用 前言 作为长期折腾云服务、域名建站的老玩家,星哥一直...
星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛NAS硬件03:五盘位+N5105+双网口的成品NAS值得入手吗

星哥带你玩飞牛 NAS 硬件 03:五盘位 +N5105+ 双网口的成品 NAS 值得入手吗 前言 大家好,我...
150元打造低成本NAS小钢炮,捡一块3865U工控板

150元打造低成本NAS小钢炮,捡一块3865U工控板

150 元打造低成本 NAS 小钢炮,捡一块 3865U 工控板 一块二手的熊猫 B3 工控板 3865U,搭...
星哥带你玩飞牛NAS-13:自动追番、订阅下载 + 刮削,动漫党彻底解放双手!

星哥带你玩飞牛NAS-13:自动追番、订阅下载 + 刮削,动漫党彻底解放双手!

星哥带你玩飞牛 NAS-13:自动追番、订阅下载 + 刮削,动漫党彻底解放双手! 作为动漫爱好者,你是否还在为...