LVS实现健康性检查功能
LVS高可用性
Director不可用,整个系统将不可用;SPoF Single Point of Failure
解决方案:高可用
keepalived heartbeat/corosync
某RS不可用时,Director依然会调度请求至此RS
解决方案: 由Director对各RS健康状态进行检查,失败时禁用,成功时启用
keepalived heartbeat/corosync ldirectord
检测方式:
(a) 网络层检测,icmp
(b) 传输层检测,端口探测
(c) 应用层检测,请求某关键资源
RS全不用时:backup server, sorry server
ldirectord
ldirectord:监控和控制LVS守护进程,可管理LVS规则
包名:ldirectord-3.9.6-0rc1.1.1.x86_64.rpm
下载:http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/x86_64/
文件:
/etc/ha.d/ldirectord.cf 主配置文件
/usr/share/doc/ldirectord-3.9.6/ldirectord.cf 配置模版
/usr/lib/systemd/system/ldirectord.service 服务
/usr/sbin/ldirectord 主程序,Perl实现
/var/log/ldirectord.log 日志
/var/run/ldirectord.ldirectord.pid pid文件
ldirectord实战演练:
1、在LVS服务器上下载ldirectord包,并安装此包
[root@lvsdata]#wget http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-7/x86_64/ldirectord-3.9.6-0rc1.1.2.x86_64.rpm
[root@lvsdata]#yum install ldirectord-3.9.6-0rc1.1.2.x86_64.rpm -y
2、查看安装后的包
[root@lvsdata]#rpm -ql ldirectord-3.9.6-0rc1.1.2
/etc/ha.d
/etc/ha.d/resource.d
/etc/ha.d/resource.d/ldirectord
/etc/logrotate.d/ldirectord
/usr/lib/ocf/resource.d/heartbeat/ldirectord
/usr/lib/systemd/system/ldirectord.service
/usr/sbin/ldirectord
/usr/share/doc/ldirectord-3.9.6
/usr/share/doc/ldirectord-3.9.6/COPYING
/usr/share/doc/ldirectord-3.9.6/ldirectord.cf
/usr/share/man/man8/ldirectord.8.gz
3、在LVS服务器上,将配置文件复制到/etc/ha.d目录下
[root@lvsdata]#cp /usr/share/doc/ldirectord-3.9.6/ldirectord.cf /etc/ha.d/
4、在LVS服务器上安装httpd服务,并启动
[root@lvsha.d]#yum install httpd -y
[root@lvsha.d]#echo Sorry Server > /var/www/html/index.html
[root@lvsha.d]#systemctl start httpd
5、在原有搭建好的LVS负载均衡调度基础上,修改此配置文件
virtual=10.0.0.100:80 添加VIP地址
real=192.168.37.19:80 gate 添加RS1IP地址
real=192.168.37.20:80 gate 添加RS2IP地址
fallback=127.0.0.1:80 gate
service=http
scheduler=rr
#persistent=600
#netmask=255.255.255.255
protocol=tcp
checktype=negotiate
checkport=80
request="index.html"
#receive="Test Page" 注释掉
#virtualhost=www.x.y.z 注释掉
6、删除原有绑定在lo网卡上的IP地址以及ipvsadm规则,并手动添加新的IP地址,绑定在回环网卡上。
[root@lvs~]#bash lvs_dr_vs.sh stop
[root@lvs~]#ifconfig lo:1 10.0.0.100/24
7、启动ldirectord,此时就会自动添加ipvsad规则。
[root@lvsdata]#systemctl start ldirectord
[root@lvsdata]#ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 rr
-> 192.168.37.19:80 Route 1 0 0
-> 192.168.37.20:80 Route 1 0 0
8、此时停止RS1服务器的httpd服务
[root@rs1~]#systemctl stop httpd
9、在LVS服务器上查看掉线之后被踢掉的ipvsadm调度规则
[root@lvsdata]#ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 rr
-> 192.168.37.20:80 Route 1 0 35
10、此时在客户端查看访问页面是RS2的页面
[root@centos6 network-scripts]# while : ;do curl 10.0.0.100;sleep 0.5;done
192.168.37.20 RS2
192.168.37.20 RS2
192.168.37.20 RS2
192.168.37.20 RS2
11、此时再恢复RS1服务器的httpd服务
[root@rs1~]#systemctl start httpd
12、ldirectord软件会自动启动RS1的ipvsadm规则。
[root@lvsdata]#ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 rr
-> 192.168.37.19:80 Route 1 0 71
-> 192.168.37.20:80 Route 1 0 97
13、在客户端访问的httpd服务页面,此时就会恢复两个RS服务器的信息。
[root@centos6 network-scripts]# while : ;do curl 10.0.0.100;sleep 0.5;done
192.168.37.19 RS1
192.168.37.20 RS2
192.168.37.19 RS1
14、此时RS1和RS2的httpd服务都停掉
[root@rs2~]#systemctl stop httpd
[root@rs1~]#systemctl stop httpd
15、此时的ipvsadm规则的回环网卡就会显示。
[root@lvsdata]#ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.100:80 rr
-> 127.0.0.1:80 Route 1 0 0
16、此时客户端就会显示LVS调度器httpd服务里边的index.html信息。
[root@centos6 network-scripts]# while : ;do curl 10.0.0.100;sleep 0.5;done
Sorry Server
Sorry Server
Sorry Server
Sorry Server
17、修改LVS服务器的ldirectord配置文件,重启服务,就会将开启httpd服务的作为优先级高的在客户端进行访问。
[root@lvsdata]#vim /etc/ha.d/ldirectord.cf
quiescent=yes
[root@lvsdata]#systemctl restart ldirectord.service

18、此时查看ipvsadm规则优先级情况,此时RS2的服务是开启的,就会只访问RS2服务器。

19、在客户端访问LVS调度器,此时调度访问的是RS2服务器。
[root@centos6 network-scripts]# while : ;do curl 10.0.0.100;sleep 0.5;done
192.168.37.20 RS2
192.168.37.20 RS2
192.168.37.20 RS2
20、而如果此时RS1的httpd服务开启之后,此时LVS服务器的ipvsadm规则中RS服务器两者的优先级就会一样,两个权重一致,就会都去访问。
[root@rs1~]#systemctl start httpd

21、在客户端访问LVS调度器的IP地址。
[root@centos6 network-scripts]# while : ;do curl 10.0.0.100;sleep 0.5;done
192.168.37.20 RS2
192.168.37.19 RS1
192.168.37.20 RS2
192.168.37.19 RS1
LVS实现健康性检查功能的更多相关文章
- LVS之3---健康检查
LVS实现健康性检查功能 LVS高可用性 解决方案: 由Director对各RS健康状态进行检查,失败时禁用,成功时启用 keepalived heartbeat/corosync ldirector ...
- LVS节点健康检查及管理脚本
在LVS负载均衡主节点上,模拟keepalived健康检查功能管理LVS节点,当节点挂掉从服务器池中剔除,好了再加到服务器池中来. 工具:yum install -y ipvsadm web03:10 ...
- nginx的健康检查功能将挂掉的Tomcat舍弃
1.Ngninx自带健康检查功能,能将挂掉的服务器舍弃,不在访问路径里 2.Nginx还有URL重写功能,能将接收到的请求,进行改写,再将新的URL分发到后端服务器上
- Tengine笔记3:Nginx的反向代理和健康状态检查
通常代理服务器只用于处理内部网络对Intenet的请求,客户端必须通过代理服务器把本来要发送到Web服务器上的请求通过代理服务器分发给Web服务器,Web服务器响应时再通过代理服务器把响应发给客户端: ...
- nginx_upstream_check_module-master对nginx的后端机器进行健康状态检查报403错误【转】
在nginx.conf配置文件中 在server添加 location /nstatus { check_status; access_log off; #allow 192.168.2.11; #d ...
- nginx健康节点检查nginx_upstream_check_module 淘宝的upstream_check进行nginx后端检查 tengine
Nginx实战系列之功能篇----后端节点健康检查 2015-01-18 22:35 5007人阅读 评论(0) 收藏 举报 分类: Nginx(28) 目录(?)[+] 公司前一段对业务 ...
- C++中重载决议与可访问性检查的顺序
http://blog.csdn.net/starlee/article/details/1406781 对于如下的类: class ClxECS{public: double Test(dou ...
- solr入门之solr的拼写检查功能的应用级别尝试
今天主要是收集了些拼写检查方面的资料和 尝试使用一下拼写检查的功能--=遇到了不少问题 拼写检查的四种配置眼下我仅仅算是成功了半个吧 --------------------------------- ...
- pod管理调度约束、与健康状态检查
pod的管理 [root@k8s-master ~]# vim pod.yaml apiVersion: v1 kind: Pod metadata: name: nginx-pod labels: ...
随机推荐
- LeetCode_226. Invert Binary Tree
226. Invert Binary Tree Easy Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: ...
- idea能用下划线替换红色报错吗?我色弱,用idea简直太痛苦了
看看下图的idea,如果某个类的包路径没有引进来,使用颜色来提示,这对于色弱的程序员简直是一种折磨,有没有可以改成eclipse的那种报错提示方式? 个人感觉idea真的没有eclipse友好,也许是 ...
- Nginx日志挂载目录为nfs文件服务器时开机无法自启动的问题解决
为了方便收集查看日志把nginx日志输出至nfs文件服务器,nfs文件服务器使用autofs自动挂载,nginx和autofs都使用systemctl设置了开机自启动. 但是在重启主机的时候nginx ...
- Docker:学习笔记(1)——基础概念
Docker:学习笔记(1)——基础概念 Docker是什么 软件开发后,我们需要在测试电脑.客户电脑.服务器安装运行,用户计算机的环境各不相同,所以需要进行各自的环境配置,耗时耗力.为了解决这个问题 ...
- RabbitMQ官方教程四 Routing(GOLANG语言实现)
在上一教程中,我们构建了一个简单的日志记录系统. 我们能够向许多消费者广播日志消息. 在本教程中,我们将向其中添加功能-我们将使仅订阅消息的子集成为可能. 例如,我们将只能将严重错误消息定向到日志文件 ...
- beyond Compare 30天过期后的处理办法
打开Beyond Compare 4,提示已经超出30天试用期限制,解决方法: 修改C:\Program Files\Beyond Compare 4\BCUnrar.dll,这个文件重命名或者直接删 ...
- Meerkat软件
一.准备工作 meerkat 0.189版本和以前的版本相比,支持bwa mem 输出的bam文件,还支持全外显子数据count SV. meerkat原理 1.1 需要准备的软件 unix/Linu ...
- TCP/IP学习笔记9--以太网之基本概念1: 分类,连接方式
时间是变化的财富.时钟模仿它,却只有变化而无财富. -- 泰戈尔 以太网(Ethernet)一词源于Ether(以太), 是介质的意思.在爱因斯坦哥们提出量子力学之前,人们普遍认为宇宙空间充满以太,并 ...
- poj1228(稳定凸包+特判最后一条边)
题目链接:https://vjudge.net/problem/POJ-1228 题意:我是真的没看懂题意QAQ...搜了才知道.题目给了n个点,问这n个点确定的凸包是否能通过添加点来变成一个新的凸包 ...
- LeetCode 144. 二叉树的前序遍历(Binary Tree Preorder Traversal)
144. 二叉树的前序遍历 144. Binary Tree Preorder Traversal 题目描述 给定一个二叉树,返回它的 前序 遍历. LeetCode144. Binary Tree ...