有关SCAN与VIP的试验(一)

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 星期一 330 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 星期一 330 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 星期一 330 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 星期一 330 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 星期一 330 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 星期一 330 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所在节点上运行的实例。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值