在Grid Infrastructure中单独网络中配置第二个监听器
在 Grid Infrastructure 安装过程中,监听器默认在public IP网络中启动服务。在某些系统中配置了1个以上的public IP网络,因此可能需要在第二个public ip网络中创建另一个独立的监听器。
下面详细介绍如何在第二个public网络上添加/创建/配置第二个侦听器。
详细配置过程
前期准备
下面是2节点RAC集群中/etc/hosts 文件或DNS配置
# public ip and vip on eth1
node1 10.96.0.1
node1-vip 10.96.0.11
node1-priv 172.168.0.1
node2 10.96.0.2
node2-vip 10.96.0.12
node2-priv 172.168.0.2
node-scan 10.96.0.3
# 2nd public ip and vip on eth2
node1n2 20.96.0.1
node1n2-vip 20.96.0.21
node2n2 20.96.0.2
node2n2-vip 20.96.0.22
## 12C scan2
node2-scan 20.96.0.3
备份OCR和gpnp配置文件
备份OCR
su - root
. /home/grid/.bash_profile
ocrconfig -export bkocr_$(date +%Y%m%d).ocr
备份gpnp配置文件
su - grid
cp $ORACLE_HOME/gpnp/$(hostname -s)/profiles/peer/profile.xml{,_$(date +%Y%m%d)}
检查当前IP相关配置
su - grid
$ORACLE_HOME/bin/oifcfg iflist -p
$ORACLE_HOME/bin/oifcfg getif
在11.2 Grid Infrastructure环境中配置方案
在11.2 版本中,一个RAC集群仅能定义一个scan名称,第二个网络不能使用相同的SCAN名称。从12C开始支持多个SCAN名称。
在CRS资源中创建第2个网络配置
主机名应该小写字符
配置VIP资源
su - root
. /home/grid/.bash_profile
# 语法
## 11.2.0.1
$ORACLE_HOME/bin/srvctl add vip -n <node_name> -k <network_number> -A <name|ip>/<netmask>/[if1[|if2...]] [-v]
## 11.2.0.2+
srvctl add network [-k <net_num>] -S <subnet>/<netmask>/[if1[|if2...]] [-w <network_type>] [-v]
# 示例
srvctl add vip -n node1 -k 2 -A node1n2-vip/255.255.255.0/eth2
srvctl add vip -n node2 -k 2 -A node2n2-vip/255.255.255.0/eth2
检查确认
crsctl stat res -t |grep -E 'net|vip'
创建监听器2
su - grid
srvctl add listener -l LISTENER2 -s -p 1521 -k 2
srvctl start listener -l LISTENER2
当使用与在用的监听器相同端口号时,需要添加-s选项
检查监听器2服务状态
lsnrctl status LISTENER2
数据库实例中配置监听相关参数
需要修改 LISTENER_NETWORKS 参数值
$TNS_ADMIN/tnsnames.ora中配置
- node1
listener1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
)
all1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
)
listener2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1n2-vip)(PORT = 1521))
)
all2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1n2-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2n2-vip)(PORT = 1521))
)
- node2
listener1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
)
all1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
)
listener2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node2n2-vip)(PORT = 1521))
)
all2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = node1n2-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = node2n2-vip)(PORT = 1521))
)
修改LISTENER_NETWORKS参数值
alter system set LISTENER_NETWORKS='((NAME=net1)(LOCAL_LISTENER=listener1)(REMOTE_LISTENER=all1))','((NAME=net2)(LOCAL_LISTENER=listener2)(REMOTE_LISTENER=all2))' scope=both sid='*';
注意:LISTENER_NETWORKS参数指定的监听器不应该在LOCAL_LISTENER 和 REMOTE_LISTENER 参数中使用,否则,将发生交叉注册,并且连接将跨网络重定向
当 LISTENER_NETWORKS 参数已设置时,集群件 oraagent 会跳过 LOCAL_LISTENER 参数(Doc ID 1602809.1)
在Grid Infrastructure软件已升级到11.2.0.3.8GIPSU或11.2.0.4的环境中,数据库实例启动过程中,当spfile中已配置 listener_networks 的情况下,会跳过配置 LOCAL_LISTENER 参数。在这种情况下,客户端连接可能会收到TNS-12502 or TNS-12170 告警信息。
处理方案
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521))','(ADDRESS=(PROTOCOL=TCP)(HOST=node1n2-vip)(PORT=1521))' scope=both sid='inst1';
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1521))','(ADDRESS=(PROTOCOL=TCP)(HOST=node2n2-vip)(PORT=1521))' scope=both sid='inst2';
alter system register;
-
tnsnames.ora配置
REMOTE_NET2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node1n2-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2n2-vip)(PORT = 1521)) ) LOCAL_NET2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node1n2)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2n2)(PORT = 1521)) ) REMOTE_NET1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node-scan)(PORT = 1521)) ) LOCAL_NET1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521)) )
-
配置LISTENER_NETWORKS参数
alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=local_net1)(REMOTE_LISTENER=remote_net1))','((NAME=network2)(LOCAL_LISTENER=local_net2)(REMOTE_LISTENER=remote_net2))' scope=both sid='*'; alter system register;
在12C环境中配置方案
增加第2网络
su - grid
oifcfg iflist
oifcfg setif -global eth2/10.96.0.0:public
su - root
. /home/grid/.bash_profile
srvctl add network -netnum 2 subnet 20.96.0.0/255.255.255.0/eth2
srvctl config network -netnum 2
srvctl config network
添加VIP
su - root
. /home/grid/.bash_profile
srvctl add vip -node node1 -netnum 2 -address node1n2-vip/255.255.255.0/eth2
srvctl add vip -node node2 -netnum 2 -address node2n2-vip/255.255.255.0/eth2
添加监听器2
su - grid
srvctl add listener -listener listener2 -netnum 2 -endpoints "TCP:1528"
添加SCAN
su - root
. /home/grid/.bash_profile
srvctl add scan -scanname node2-scan -netnum 2
启动VIP服务
su - root
srvctl start vip -vip node1n2-vip
srvctl start vip -vip node2n2-vip
启动监听2服务
su - grid
srvctl start listener -listener listener2
srvctl status listener -listener listener2
启动scan2服务
su - root
srvctl start scan -netnum 2
添加scan2 listener服务并启动
su - grid
srvctl add scan_listener -netnum 2 -listener scanlsnr_2 -endpoints "TCP:1523"
srvctl start scan_listener -netnum 2
检查配置
srvctl config scan -netnum 2
srvctl status scan -netnum 2
附录
参考文档
-
How to Configure A Second Listener on a Separate Network in Grid Infrastructure (Doc ID 1063571.1)
-
11gR2: Clusterware Oraagent doesn't set the local_listener when listener_networks is set in the spfile. (Doc ID 1602809.1)
-
12c: How to Create Additional SCAN/SCAN VIP (Doc ID 2138078.1)