绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
RAC环境下如何修改监听端口
2021-05-31 21:35:00

近有一个业务需求,修改Oracle 默认的网络端口号,将1521修改为1881,修改熟知的Oracle监听端口也是安全考虑,这个操作不需要停应用,但是对于网络连接还是会有点影响,应用也需要修改连接的数据库服务端口。下面是在基于RAC架构的数据库层面如何修改监听端口的测试过程。

1 查看当前监听的信息

[root@test1 ~]# srvctl config listener;
Name: LISTENER
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1521

当前本地监听端口为1521,监听名字为LISTENER .


2 修改本地监听端口

[root@test1 ~]# srvctl modify listener -l LISTENER -p "TCP:1881"
[root@test1 ~]# srvctl config listener;
Name: LISTENER
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1881
Listener is enabled.

3 修改SCAN_IP

[root@test1 ~]# srvctl modify scan_listener -p 1881
[root@test1 ~]# srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1881


4 修改remote_listener和local_listener的参数设置

SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.103)(PORT=1881))' scope=both sid='prod_1';

System altered.

SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.104)(PORT=1881))' scope=both sid='prod_2';

System altered.

SQL> alter system set remote_listener='test-scan:1881' scope=both;

System altered.


5修改验证

SQL> host srvctl config Listener
Name: LISTENER
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1881
Listener is enabled.
Listener is individually enabled on nodes:
Listener is individually disabled on nodes:

SQL> host srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1881
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:

6 业务验证

[oracle@test1 ~]$ sqlplus scott/oracle@test1:1521/prod         <<<<<<<<<端口1521失败

SQL*Plus: Release 12.1.0.2.0 Production on Fri May 28 11:34:59 2021

Copyright (c) 1982, 2014, Oracle. All rights reserved.

ERROR:
ORA-12541: TNS:no listener


Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus


[oracle@test1 ~]$ sqlplus scott/oracle@test1:1881/prod             <<<<<<<<端口1881连接成功

SQL*Plus: Release 12.1.0.2.0 Production on Fri May 28 11:35:04 2021

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Last Successful login time: Fri May 28 2021 11:34:52 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> 

注意:文件endpoints_listener.ora中的端口信息没有修改,需要重启集群才能生效。

grid@test1 admin]$ cat endpoints_listener.ora
#Backup file is /oracle/asm/network/admin/endpoints_listener.ora.bak.test1 line added by Agent
LISTENER_TEST1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=test1-vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.101)(PORT=1521)(IP=FIRST)))) # line added by Agent

重启集群,再验证修改结果如下

[root@test1 admin]# cat endpoints_listener.ora
#Backup file is /oracle/asm/network/admin/endpoints_listener.ora.bak.test1 line added by Agent
LISTENER_TEST1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=test1-vip)(PORT=1881))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.101)(PORT=1881)(IP=FIRST)))) # line added by Agent


集群状态

[root@test1 admin]# crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMCRS.dg
ONLINE ONLINE test1 STABLE
ONLINE ONLINE test2 STABLE
ora.ASMVG1.VOL1.advm
ONLINE ONLINE test1 Volume device /dev/a
sm/vol1-84 is online
,STABLE
ONLINE ONLINE test2 Volume device /dev/a
sm/vol1-84 is online
,STABLE
ora.ASMVG1.VOL2.advm
ONLINE ONLINE test1 Volume device /dev/a
sm/vol2-84 is online
,STABLE
ONLINE ONLINE test2 Volume device /dev/a
sm/vol2-84 is online
,STABLE
ora.ASMVG1.dg
ONLINE ONLINE test1 STABLE
ONLINE ONLINE test2 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE test1 STABLE
ONLINE ONLINE test2 STABLE
ora.asm
ONLINE ONLINE test1 Started,STABLE
ONLINE ONLINE test2 Started,STABLE
ora.asmvg1.vol1.acfs
ONLINE ONLINE test1 mounted on /stage,ST
ABLE
ONLINE ONLINE test2 mounted on /stage,ST
ABLE
ora.asmvg1.vol2.acfs
ONLINE ONLINE test1 mounted on /sharedac
fs,STABLE
ONLINE ONLINE test2 mounted on /sharedac
fs,STABLE
ora.net1.network
ONLINE ONLINE test1 STABLE
ONLINE ONLINE test2 STABLE
ora.ons
ONLINE ONLINE test1 STABLE
ONLINE ONLINE test2 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE test1 STABLE
ora.MGMTLSNR
1 OFFLINE OFFLINE STABLE
ora.cvu
1 ONLINE ONLINE test1 STABLE
ora.oc4j
1 ONLINE ONLINE test1 STABLE
ora.prod.db
1 ONLINE ONLINE test1 Open,STABLE
2 ONLINE ONLINE test2 Open,STABLE
ora.scan1.vip
1 ONLINE ONLINE test1 STABLE
ora.test1.vip
1 ONLINE ONLINE test1 STABLE
ora.test2.vip
1 ONLINE ONLINE test2 STABLE
--------------------------------------------------------------------------------






分享好友

分享这个小栈给你的朋友们,一起进步吧。

Oracle运维新鲜事-技术与管理各占半边天
创建时间:2020-08-04 11:34:57
本技术栈旨在分享技术心得,运维趣事,故障处理经验,调优案例,故障处理涉及集群,DG,OGG,大家生产中遇到的问题基本都会囊括了,我会发布生产库遇到的故障,希望在交流中互助互益,共同提高,也希望大家讨论,如果您有生产中遇到的集群问题,也可以在这里提出来,一起讨论,现实中也帮助不少同学解决了生产库的故障。
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

栈主、嘉宾

查看更多
  • Abraham林老师
    栈主
  • 小雨滴
    嘉宾
  • hawkliu
    嘉宾
  • u_97a59a25246404
    嘉宾

小栈成员

查看更多
  • 栈栈
  • dapan
  • 小菜鸟___
  • hwayw
戳我,来吐槽~