在11gR2中,引入了SCAN(Single Client Access Name)的特性,该特性的好处在于,在
数据库与客户端之间,添加了一层虚拟的服务层,就是所谓的scan ip以及scan ip listener,在客户端仅需要配置scan ip的tns信息,通过scan ip listener,连接后台集群数据库。这样,不论集群数据库是否有添加或者删除节点的操作,均不会对client产生影响。当有客户端应用程序使用SCAN ip访问数据库时,scan listener会将连接转发到local listener上。
RAC=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=SCAN)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=RAC))
)
Client should connect to the SCAN name -> scan listener, scan listener will redirect the connection(sometimes beneath) to the node VIP, and all succeeding procedures are same with the previous versions.
和SCAN ip 相关的ip信息在SCAN 资源创建的时候就被初始化了。在不使用GNS的情况下:任何对DNS和/etc/hosts 中SCAN 中的变更都不会自动同步到Clusterware中而是要手工执行相关的更新操作。下面介绍一下修改scan ip的具体步骤:
实验环境:
版本:
Clusterware :11.2.0.2
database :11.2.0.1
旧scan ip
10.250.7.210
新scan ip
10.250.7.141
10.250.7.142
10.250.7.143
1 查看scan ip的状态信息:
grid@rac1:/home/grid>srvctl config scan
SCAN 名称: scan, 网络: 1/10.250.7.0/255.255.255.0/eth0
SCAN VIP 名称: scan1, IP: /scan/10.250.7.210
grid@rac1:/home/grid>
2 停止scan_listener ,scan 应用
grid@rac1:/home/grid>srvctl stop scan_listener
grid@rac1:/home/grid>srvctl stop scan
3 确认 scan_listener,scan 的状态
grid@rac1:/home/grid>srvctl status scan_listener
SCAN 监听程序 LISTENER_SCAN1 已启用
SCAN 监听程序 LISTENER_SCAN1 未运行
grid@rac1:/home/grid>srvctl status scan
SCAN VIP scan1 已启用
SCAN VIP scan1 未运行
grid@rac1:/home/grid>crs_stat -t | grep scan
ora.scan1.vip ora....ip.type OFFLINE OFFLINE
grid@rac1:/home/grid>
grid@rac1:/home/grid>
grid@rac1:/home/grid>crs_stat -t | grep lsnr
ora....ER.lsnr ora....er.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type OFFLINE OFFLINE
ora....C1.lsnr application ONLINE ONLINE rac1
ora....C2.lsnr application ONLINE ONLINE rac2
4 在所有节点中 /etc/hosts 文件中修改 scan 对应的ip:
10.250.7.141 scan
10.250.7.142 scan
10.250.7.143 scan
grid@rac1:/home/grid>srvctl modify scan -h
修改 SCAN 名称。
用法: srvctl modify scan -n <scan_name>
-n <scan_name> 域名限定的 SCAN 名
-h 输出用法
grid 用户无权更改scan ip,必须使用root权限
grid@rac1:/home/grid>srvctl modify scan -n scan
PRCS-1034 : 无法修改单客户机访问名 scan
PRCR-1071 : 无法注册或更新 资源类型 ora.scan_vip.type
CRS-0245: User does not have enough privilege to perform. the operation
[root@rac1 ~]# /opt/11202/11.2.0/grid/bin/srvctl modify scan -n scan
5 变更后,进行确认:
[root@rac1 ~]# /opt/11202/11.2.0/grid/bin/srvctl config scan
SCAN 名称: scan, 网络: 1/10.250.7.0/255.255.255.0/eth0
SCAN VIP 名称: scan1, IP: /scan/10.250.7.141 <====只有一个scan ip
对于/etc/hosts文件解析scan ip,因为不能做轮训的负载均衡,所以这时候scan ip就只能有一个了。
6 重新启动scan,scan_listener
grid@rac1:/home/grid>srvctl start scan
grid@rac1:/home/grid>srvctl start scan_listener
7 确认scan 和scan_listener.ora的状态:
grid@rac1:/home/grid>crs_stat -t | grep scan
ora.scan1.vip ora....ip.type ONLINE ONLINE rac2
grid@rac1:/home/grid>crs_stat -t | grep lsnr
ora....ER.lsnr ora....er.type ONLINE ONLINE rac1
ora....N1.lsnr ora....er.type ONLINE ONLINE rac2
ora....C1.lsnr application ONLINE ONLINE rac1
ora....C2.lsnr application ONLINE ONLINE rac2
进行ping测试
grid@rac1:/home/grid>ping 10.250.7.141
PING 10.250.7.141 (10.250.7.141) 56(84) bytes of data.
64 bytes from 10.250.7.141: icmp_seq=1 ttl=64 time=1.52 ms
64 bytes from 10.250.7.141: icmp_seq=2 ttl=64 time=0.226 ms
--- 10.250.7.141 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.226/0.873/1.520/0.647 ms
grid@rac1:/home/grid>ping 10.250.7.142
PING 10.250.7.142 (10.250.7.142) 56(84) bytes of data.
与修改private ip ,vip 不一样,修改scan ip 无需停止数据库实例,
asm 或者重启crs,相对比较简单!