SCAN是oracle 11g RAC推出的技术。
下面是官方文档对SCAN的描述:
The SCAN is a name used to provide service access for clients to the cluster. Because the SCAN is associated with the cluster as a whole, rather than to a particular node, the SCAN makes it possible to add or remove nodes from the cluster without needing to reconfigure clients. It also adds location independence for the databases, so that client configuration does not have to depend on which nodes are running a particular database. Clients can continue to access the cluster in the same way as with previous releases, but Oracle recommends that clients accessing the cluster use the SCAN.
但是对于VIP和SCAN的作用很容易就混淆了,所以自己做了下面的试验。来比较VIP和SCAN的区别。
环境配置
- 操作系统: Oracle Linux 6.6 64bit
- 数据库:Oracle RAC 11.2.0.3.9
- VIP:192.168.56.201, 192.168.56.202
- SCAN:192.168.56.110,192.168.56.111,192.168.56.112
- 节点1上的实例:PROD1
- 节点2上的实例:PROD2
TNS配置
SCAN连接prod1
PROD1.scan=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.56.110)
(PORT=1521)
)
(CONNECT_DATA=
(INSTANCE_NAME=PROD1)
(SERVICE_NAME=PROD)
)
)
SCAN连接prod2
PROD2.scan=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.56.110)
(PORT=1521)
)
(CONNECT_DATA=
(INSTANCE_NAME=PROD2)
(SERVICE_NAME=PROD)
)
)
vip1连接prod1
PROD1.vip1=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=db01-vip)
(PORT=1521)
)
(CONNECT_DATA=
(INSTANCE_NAME=PROD1)
(SERVICE_NAME=PROD)
)
)
vip1连接prod2
PROD2.vip1=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=db01-vip)
(PORT=1521)
)
(CONNECT_DATA=
(INSTANCE_NAME=PROD2)
(SERVICE_NAME=PROD)
)
)
vip2连接prod1
PROD1.vip2=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=db02-vip)
(PORT=1521)
)
(CONNECT_DATA=
(INSTANCE_NAME=PROD1)
(SERVICE_NAME=PROD)
)
)
vip2连接prod2
PROD2.vip2=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=db02-vip)
(PORT=1521)
)
(CONNECT_DATA=
(INSTANCE_NAME=PROD2)
(SERVICE_NAME=PROD)
)
)
测试过程
vip1连接prod1
[oracle@db01 admin]$ sqlplus system/oracle@prod1.vip1
SQL*Plus: Release 11.2.0.4.0 Production on 星期一 3月 30 22:17:39 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
PROD1
SQL> exit
vip1连接prod2
[oracle@db01 admin]$ sqlplus system/oracle@prod2.vip1
SQL*Plus: Release 11.2.0.4.0 Production on 星期一 3月 30 22:18:33 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS: 无法解析指定的连接标识符
请输入用户名:
vip2连接prod1
[oracle@db01 admin]$ sqlplus system/oracle@prod1.vip2
SQL*Plus: Release 11.2.0.4.0 Production on 星期一 3月 30 22:59:42 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-12521: TNS: 监听程序当前无法识别连接描述符中请求的实例
请输入用户名:
vip2连接prod2
[oracle@db01 admin]$ sqlplus system/oracle@prod2.vip2
SQL*Plus: Release 11.2.0.4.0 Production on 星期一 3月 30 22:39:21 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
SQL>
scan连接prod1
[oracle@db01 admin]$ sqlplus system/oracle@prod1.scan
SQL*Plus: Release 11.2.0.4.0 Production on 星期一 3月 30 23:00:33 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
PROD1
SQL> exit
用scan连接prod2
[oracle@db01 admin]$ sqlplus system/oracle@prod2.scan
SQL*Plus: Release 11.2.0.4.0 Production on 星期一 3月 30 22:48:40 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, Oracle Label Security,
OLAP, Data Mining, Oracle Database Vault and Real Application Testing options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
PROD2
结论
通过这个试验可以知道:
通过单一的scan IP可以连接所有实例。
通过单一的VIP只能够连接VIP所在节点上运行的实例。