修改Oracle默认监听端口

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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/73249a42de8a5d873cb32db4574b8438.html