SCAN的作用是简化客户端连接数据库的配置,无论集群增加还是删除节点SCAN名称会一直保持不变,客户端不需要做任何的修改。SCAN是一个名称,通过DNS被解析成最多3个IP地址(SCAN VIP)
SCAN VIP的作用是接收客户端连接,SCAN VIP必须与集群的公网资源处于相同的子网,每一个SCAN VIP都会有对应的SCAN LISTENER,并且SCAN LISTENER只会监听对应的SCAN VIP,而且它们必须运行在同一个节点。SCAN VIP会均匀地分布在集群的各个节点,例如:一个包含了8个节点的集群,会选择其中3个节点运行SCAN VIP,当运行SCAN VIP的节点出现问题时,SCAN VIP会漂移到其他正常节点,对于一个两节点的集群,如果配置了3个SCAN VIP,一定会有一个节点存在两个SCAN VIP ,另一个节点存在一个SCAN VIP。
SCAN VIP和SCAN LISTENER以集群资源的形式存在,由集群的代理进程进行统一管理,SCAN VIP依赖于集群的公网资源,而SCAN LISTENER依赖于对应的SCAN VIP资源,当本地节点出现问题SCAN VIP漂移到其他节点后,对应的SCAN LISTENER也需要随着SCAN VIP一起漂移。
通过SCAN连接到数据库
阶段1:每个节点的PMON进程通过访问数据库信息将本地实例提供的服务注册到本地节点的监听程序和每一个SCAN监听程序。其中local_listener指定了PMON需要注册的本地监听程序位置,而remote_listener指定了需要注册的SCAN监听程序位置,之后,无论是本地节点的监听程序,还是SCAN监听程序都已经为接收客户端的连接做好准备。
阶段2:客户端通过tnsnames.ora中的别名向SCAN监听程序发起连接,由于SCAN监听程序分布在集群的不同节点,连接到哪个节点取决于DNS将SCAN名解析成哪一个节点的SCAN VIP(DNS使用轮询的方式返回SCAN对应的IP地址)。
阶段3:SCAN监听程序在收到了客户端发送的请求后,根据每个节点的负责情况,将客户端连接转发给负载最低的节点本地监听程序,之后对应节点的本地监听程序完成与客户端的连接。
[grid@node01 ~]$ srvctl config scan
SCAN name: cluster.gscaifu.com, Network: 1/192.168.1.0/255.255.255.0/enp0s10
SCAN VIP name: scan1, IP: /cluster.gscaifu.com/192.168.1.202
SCAN VIP name: scan2, IP: /cluster.gscaifu.com/192.168.1.201
SCAN VIP name: scan3, IP: /cluster.gscaifu.com/192.168.1.203
[grid@node01 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node node02
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node node01
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node node01
[grid@node01 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
[grid@node01 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node node02
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node node01
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node node01
[grid@node01 ~]$ lsnrctl status LISTENER
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2023 18:57:17
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 19-AUG-2023 17:09:25
Uptime 0 days 1 hr. 47 min. 52 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/node01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.101)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.111)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "core" has 1 instance(s).
Instance "core1", status READY, has 1 handler(s) for this service...
Service "coreXDB" has 1 instance(s).
Instance "core1", status READY, has 1 handler(s) for this service...
Service "soe" has 1 instance(s).
Instance "core1", status READY, has 1 handler(s) for this service...
The command completed successfully
[grid@node01 ~]$ lsnrctl status LISTENER_SCAN2
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-AUG-2023 18:58:07
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))
STATUS of the LISTENER
------------------------
Alias LISTENER_SCAN2
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 19-AUG-2023 17:09:24
Uptime 0 days 1 hr. 48 min. 42 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File /u01/app/11.2.0.4/grid/log/diag/tnslsnr/node01/listener_scan2/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN2)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.201)(PORT=1521)))
Services Summary...
Service "core" has 2 instance(s).
Instance "core1", status READY, has 1 handler(s) for this service...
Instance "core2", status READY, has 1 handler(s) for this service...
Service "coreXDB" has 2 instance(s).
Instance "core1", status READY, has 1 handler(s) for this service...
Instance "core2", status READY, has 1 handler(s) for this service...
Service "soe" has 1 instance(s).
Instance "core1", status READY, has 1 handler(s) for this service...
The command completed successfully
标签:status,...,RAC,SCAN,Database,LISTENER,VIP,节点
From: https://blog.51cto.com/dbprofessional/7151907