目录
oracle rac监听和oracle单节点监听不同,rac监听分为远程监听和本地监听:
远程监听即remote_listener也是scan_listener
本地监听即local_listener也是listener
local_listener 默认不需要配置,默认配置指向1521端口,对于需要单实例连接rac数据库实例且对端口有要求的情况,需要改变本地监听端口指向tns里的连接字符串,而在rac配置中默认指向本节点的vip。
remote_listener指向的是scan监听名,需要远程监听配置
单节点执行
切换至grid账号下
[grid@db1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521 #远程监听端口为1521
[grid@db1 ~]$ lsnrctl status LISTENER_SCAN1
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-2020 22:17:50
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
STATUS of the LISTENER
------------------------
Alias LISTENER_SCAN1
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 10-MAR-2020 22:02:49
Uptime 1 days 0 hr. 15 min. 1 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/app/grid/11.2.0/log/diag/tnslsnr/db1/listener_scan1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.242.124.205)(PORT=1521))) ## 远程监听端口为1521
Services Summary...
Service "orcl" has 2 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
Instance "orcl2", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 2 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
Instance "orcl2", status READY, has 1 handler(s) for this service...
The command completed successfully
scan_listener如果不在节点1,则在另外一个节点查看
在grid用户下进行,命令格式如下
Modify SCAN listener port:
$GRID_HOME/bin/srvctl modify scan_listener -p
Update 11gR2 database init.ora parameter: alter system set remote_listener=':' scope=both;
示例:
[grid@db1 ~]$ $GRID_HOME/bin/srvctl modify scan_listener -p 1525
切换到oracle节点执行
SQL> show parameter listener NAME TYPE VALUE
[root@db1 ~]# su - oracle
[oracle@db1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 11 22:31:15 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> show parameter listener NAME TYPE VALUE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=10.2
42.124.203)(PORT=1521))))
remote_listener string dbscan:1521 ##远程监听端口为1521
SQL> alter system set remote_listener='dbscan:1525' scope=both;
System altered.
SQL> show parameter listener NAME TYPE VALUE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=10.2
42.124.203)(PORT=1521))))
remote_listener string dbscan:1525 ##远程监听端口已经修改为1525
切换至grid
[grid@db1 ~]# srvctl stop scan_listener
[grid@db1 ~]# srvctl start scan_listener
[grid@db1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1525
[grid@db1 ~]$ lsnrctl status LISTENER_SCAN1
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-2020 22:40:51
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
STATUS of the LISTENER
------------------------
Alias LISTENER_SCAN1
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 10-MAR-2020 22:02:49
Uptime 1 days 0 hr. 38 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/app/grid/11.2.0/log/diag/tnslsnr/db1/listener_scan1/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.242.124.205)(PORT=1525))) #远程节点端口已经修改为1525
Services Summary...
Service "orcl" has 2 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
Instance "orcl2", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 2 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
Instance "orcl2", status READY, has 1 handler(s) for this service...
The command completed successfully
发现rac集群远端监听端口已经修改完毕
使用sqlplus连接正常
双节点都要执行
切换到grid执行
[grid@db1 ~]$ srvctl config listener
Name: LISTENER
Network: 1, Owner: grid
Home: <CRS home>
End points: TCP:1521 #本地监听端口为1521
[grid@db1 ~]$ lsnrctl status #查看监听状态
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-2020 23:11:02
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 10-MAR-2020 22:02:49
Uptime 1 days 1 hr. 8 min. 13 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/grid/diag/tnslsnr/db1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.242.124.201)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.242.124.203)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@db1 ~]$ srvctl modify listener -l LISTENER -p "TCP:1525"
切换到oracle用户执行
[root@db1 ~]# su - oracle
[oracle@db1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 11 22:59:39 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> show parameter listener NAME TYPE VALUE
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=10.2
42.124.203)(PORT=1521)))) #本地端口为1521
remote_listener string dbscan:1525
SQL>alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.2
42.124.203)(PORT=3521))))' scope=both sid='orcl1' # 此处HOST为节点虚地址vip,sid为节点进程ID
System altered.
SQL>alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.2
42.124.204)(PORT=3521))))' scope=both sid='orcl1' # 此处HOST为节点虚地址vip,sid为节点进程ID
System altered.
SQL> show parameter listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
listener_networks string
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=10.2
42.124.203)(PORT=1525))))
remote_listener string dbscan:1525 #本地端口已经修改
切换到grid用户执行
[grid@db1 ~]# srvctl stop listener
[grid@db1 ~]# srvctl start listener
[grid@db1 ~]$ lsnrctl status #查看监听状态
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 11-MAR-2020 23:11:02
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 10-MAR-2020 22:02:49
Uptime 1 days 1 hr. 8 min. 13 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/grid/11.2.0/network/admin/listener.ora
Listener Log File /u01/grid/diag/tnslsnr/db1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.242.124.201)(PORT=1525))) # 实地址端口已经改为1525
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.242.124.203)(PORT=1525))) # 虚地址端口已经改为1525
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
The command completed successfully
发现节点1得本地监听端口已经修改完成,在节点2重复上述步骤,完成节点2本地监听端口得修改即可
使用sqlplus连接正常
oracle 11g rac修改监听端口(远程监听和本地监听)
原文:https://www.cnblogs.com/yj411511/p/12466463.html