当前位置:  数据库>oracle

修改Oracle默认监听端口

    来源: 互联网  发布时间:2017-06-26

    本文导语: 我们都知道,Oracle的监听默认端口是1521,但是如果系统上1521已经被占用或业务要求不用默认端口,则需要修改监听的默认端口。修改监听端口只需要修改配置文件listiner.ora,然后重启监听就行了。但是Oracle实例的PMON进程还是会...

我们都知道,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>


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • sqlserver iis7站长之家
  • 在装了xp后再装linux,现在grub默认启动是linux,如何修改,让默认启动为xp?
  • 我想把默认的登陆系统改为dos 想延长默认的时间,修改/etc /lilo.conf没有成功,怎么回事啊
  • 修改mysql5.5默认编码(图文步骤修改为utf-8编码)
  • 如何修改RedHat8启动延时及默认启动的系统?
  • android 默认时间格式修改方法
  • linux修改系统默认编码
  • 怎么修改SCIM的一些默认设置
  • 如何修改linux的默认登陆用户
  • openssl修改默认参数的api
  • 修改Oracle默认用户密码有效期时间
  • 怎样修改linux的默认编码?
  • 刚装了debian,怎么修改命令行的默认语言
  • Solaris下如何修改java虚拟机的默认编码
  • 在windows 7 系统下安装了CentOS 默认进入的是CentOS如何修改?
  • 怎样修改emacs的默认的tab stops
  • mssql对已创建表的某个字段修改为默认值
  • 如何修改Linux下编程时系统的默认头文件?
  • 【新手】又有问题,该如何修改tomcat4默认路径?
  • 那里修改配置可以做到系统登陆进入默认是控制台,而不是图形界面?
  • 如何修改红旗Linux下FTP的默认目录?
  • 修改Windows硬盘分区名称
  • unix 下 C++实现 ftp 到另一台主机上 修改文件内容 !能不能直接在主机上修改 还是只能get下来本地修改完后 在put上去
  • 修改配置真正解决php文件上传大小限制问题(apache+php)
  • 高手帮帮忙!!! 在线等!!outlook的附件修改且保存后,再次打开发现是修改之前的原件
  • 修改配置真正解决php文件上传大小限制问题(nginx+php)
  • 修改ip地址的话应该修改/ect下哪个文件里的内容?
  • mysql中如何查看最大连接数(max_connections)和修改最大连接数
  • 原密码被人恶意修改,如何修改suse系统的超级用户密码(急)
  • sharepoint 2010中item.Update()和item.SystemUpdate 修改数据版本问题解决
  • 有什么命令可以修改整个目录下文件的最后修改时间?


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3