Oracle change port 1521 TCPs

col name for a20
col value for a200
select name ,value from gv$parameter a where a.NAME like '%listener%';

(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.6)(PORT=1521)),(ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.6)(PORT=1522))

 prod1-scan:1521

(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.7)(PORT=1521)),(ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1522))

 prod1-scan:1521

(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.5)(PORT=1521)),(ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.5)(PORT=1522))

 prod1-scan:1521

 (ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.6)(PORT=1623)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.6)(PORT=1522)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.6)(PORT=1622))

 nonprod2-scan:1623

 (ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.7)(PORT=1623)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1522)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1622))

 nonprod2-scan:1623

----

However, if you are changing the default listener port number, the database instances will not be able to register themselves with this new listener as the database will contact the listener(s) on the default port 1521.

lsnrctl status

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-AUG-2023 18:08:42

Copyright (c) 1991, 2023, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
 

netstat -ntpu|grep 1521
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
 

How do you change the default port 1521 to another port for a RAC configuration?
 

SOLUTION

To get the current settings of your listener on RAC issue the following command:

> srvctl config listener

The output should be similar to the following

Name: LISTENER
Network: 1, Owner: oracle
Home: <CRS home>
End points: TCP:1521

Points to bear in mind: 

+ The ILOM server is independent of the listener and will require no changes. (Exadata)

+ Cell Servers do not have Oracle Listeners on them and will also require no changes (Exadata)

+ At some point you have to restart the listener on each node. Depending on how your services are set up you may 'drive' traffic to one node if there are many connections. For this reason these changes should be done during a quiet time. 

Steps to achieve the changes

(1) Amend the ports used with a command similar to the following

> srvctl modify listener -l LISTENER -p "TCP:<new-listener-port>"

srvctl modify scan_listener -p "TCP:1623/TCPS:1522/TCPS:1622"

This changes the entry in OCR, so that a listener restart will pick up the new values. Existing connections will remain connected.

(2) Modify the scan listener if applicable with

> srvctl modify scan_listener -p <new-scan-port>

(3) LOCAL_LISTENER should be changed manually

An example would be

SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<Host-name>)(PORT=<new-port-number>))))' scope=both sid='[<your-chosen-instance> | * ] '

(4) Make similar changes to the REMOTE_LISTENER

(5) endpoints_listener.ora and local_listener.ora for each SID are only changed after the listener is stopped and restarted.

Per Internal Bug 27486484
 The listener agent should not longer create/maintain endpoints_listener.ora from 19.1,
 also 19.1 GI does not support database earlier than 11.2.

(6) Check the configuration afterwards with "srvctl config Listener".

How do we change the default listener (TCP) port number ?
 

SOLUTION

By default, after installing Oracle Database Server, the Listener service will wait for and accept connections on TCP port 1521. However, it is possible to reconfigure the listener to use a different port. The procedure comprises two steps: reconfiguring the listener and reconfiguring the database instance(s) to register to the listener on the new, non-default port.

You may not use ports numbered lower than 1024 as these require special user privileges. The maximum value is around 65500.   Oracle does not recommend using a port in the ephemeral range for the listener.  Please see your specific OS documentation for information regarding the ephemeral port range.  Please consult Oracle's Installation Guide for your OS and RDBMS version as well.  
 

There are two ways to achieve this: through the configuration tools or by manually adjusting the appropriate configuration files. The preferred way is to use the configuration tools.

A. Using Configuration Tools
 

Before changing the listener configuration you should stop it  run the following command: "lsnrctl stop".

Launch Oracle Net Manager (execute "netmgr" at the command line) and follow these steps:

  • Select Local / Listeners / LISTENER in the left pane
  • Select Listening Locations in the right pane upper selection button
  • Browse through the AddressX tabs and choose the one with Protocol TCP/IP
  • Change the value in the Port: field to your desired port number.
  • In the left pane select Local / Service Naming
  • Create a new Net Service Name:
    • Click the green plus ("+") icon on the leftmost toolbar; dialog will appear
    • Type a name for the new Service Name (e.g. MYLISTENER); press Next
    • Select TCP/IP (Internet Protocol); press Next
    • Type your hostname in Hostname: field and the same port number you chose in the previous steps in the Port Number: field; press Next
    • Type the name of an existent database (e.g. ORCL); press Next
    • Optionally you may Test the new connection
    • Press Finish
  • Select from menus File / Save Network Configuration and close the Net Manager

Restart the listener by running the following commands at the command prompt: "lsnrctl start".

However, after you changed the default listener port number, the database instances will not be able to register themselves with this new listener as the database will contact the listener(s) on the default port 1521. To fix this problem you need to add/change the "local_listener" initialization parameter for each database.

Use Oracle Enterprise Manager to change the "local_listener" initialization parameter to have the value "MYLISTENER" for the database(s) you work with or create in the future. Make sure you make this change permanent by storing it in the SPFile, in which case you need to restart the database instance to take effect.

B. Using Configuration Files

Before changing the listener configuration you should stop it by running the following command: "lsnrctl stop".

The Oracle Listener is configured through the LISTENER.ORA file, which, by default is located in ORACLE_HOME under the NETWORK / ADMIN subdirectory. Edit this file with you preferred text editor and change the (PORT=1521) from under the default LISTENER profile to your desired value. If you do not have this file then you may use the following sample:

LISTENER =
    (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
        (ADDRESS = (PROTOCOL = TCP)(HOST = myhostname)(PORT = myport))
    )


Please replace "myhostname" with your system hostname and "myport" with your desired port number. After changing the LISTENER.ORA file you need to restart the listener. To do that run the following commands at the command prompt: "lsnrctl start".

However, if you are changing the default listener port number, the database instances will not be able to register themselves with this new listener as the database will contact the listener(s) on the default port 1521.

To fix this problem you need to add/change the "local_listener" initialization parameter for each database. This can be achieved in two steps: creating a alias name for the new listener and adjusting the LOCAL_LISTENER initialization parameter.

In the TNSNAMES.ORA file (in the same location as LISTENER.ORA) add the following entry:

MYLISTENER =
    (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = myserver )(PORT = myport))
)


Please replace the "myhostname" and "myport" with the values used for listener configuration in LISTENER.ORA.

Now adjust the LOCAL_LISTENER parameter — use the following SQL statement as SYSDBA:

ALTER SYSTEM SET LOCAL_LISTENER='MYLISTENER' SCOPE=BOTH  

--可以直接写(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.7)(PORT=1623)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1522)), (ADDRESS=(PROTOCOL=TCPS)(HOST=x.x.x.7)(PORT=1622)) 不用修改tnsnames.ora 防止文件被删了

Please take into consideration the effect of the SCOPE argument (as shown above it will also save the change in the spfile); also you may want to restrict the change to a certain instance with the help of the SID='<db_sid>' argument, if you employ a common spfile for many instances.

Please note that you may need to run this command for each Oracle database you have or which you will create on the server.


For the reference documentation see Oracle Database Net Services Administrator's Guide, Chapter "Configuring and Administering the Listener".
For RAC and/or SCAN please see:
Changing Listener Ports On RAC/EXADATA (Doc ID 1473035.1)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值