RAC环境下如何修改监听端口
近有一个业务需求,修改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
--------------------------------------------------------------------------------
相关文章