在集群中的初始配置SCAN只有一个IP,需要再增加两个IP。增加过程记录如下:
1. 查看原SCAN配置
# srvctl config scan
SCAN name: ora-node-scan, Network: 1
Subnet IPv4: 10.1.7.0/255.255.255.0/eth0, static
Subnet IPv6:
SCAN 0 IPv4 VIP: 10.1.7.240
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
# srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
2. 在hosts文件中,增加IP配置
# vim /etc/hosts
# 将下面最后2行添加到文件中
10.1.7.240 rac-scan
10.1.7.239 rac-scan
10.1.7.238 rac-scan
注意:其它节点该文件同步更新。
3. 停止SCAN服务和监听
# srvctl stop scan_listener
# srvctl stop scan
# srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
4. 修改SCAN信息,增加SCAN监听的IP
# srvctl modify scan -n rac-scan
# srvctl modify scan_listener -u
# srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is not running
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is not running
5. 重启SCAN服务和监听
# srvctl start scan
# srvctl start scan_listener
也可以直接启动监听,会自动启动scan的。
检查增加的结果和状态。
# srvctl config scan
SCAN name: rac-scan, Network: 1
Subnet IPv4: 10.1.7.0/255.255.255.0/eth0, static
Subnet IPv6:
SCAN 0 IPv4 VIP: 10.1.7.240
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
SCAN 1 IPv4 VIP: 10.1.7.239
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
SCAN 2 IPv4 VIP: 10.1.7.238
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes:
SCAN VIP is individually disabled on nodes:
# srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
Registration invited nodes:
Registration invited subnets:
SCAN Listener is enabled.
SCAN Listener is individually enabled on nodes:
SCAN Listener is individually disabled on nodes:
# srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node ora-node3
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node ora-node2
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node ora-node1
# srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node ora-node3
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node ora-node2
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node ora-node1
该过程在12c上操作,11g适用。
6. 客户端如何使用SCAN连接数据库
集群环境安装完成后,客户端是不能使用SCAN连接数据库的,报出错误,如下:
需要进行如下配置。
SQL> show parameter local_listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=
10.1.7.88)(PORT=1521))
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=rac-scan)(PORT=1521))))' scope=both;
System altered.
在客户端将如下信息加入hosts文件(windows和linux的位置不同)
10.1.7.240 rac-scan
10.1.7.239 rac-scan
10.1.7.238 rac-scan
现在再使用客户端,通过SCAN就可以连接数据库了。
C:\Users\Administrator>sqlplus test/oracle@rac-scan:1521/MKDB
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jun 2 14:23:31 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
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> select * from dual;
D
-
X
SQL> select * from tab1;
COL1
----------
SECOND