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: ...
随机推荐
- 最基础的Python的socket编程入门教程
最基础的Python的socket编程入门教程 本文介绍使用Python进行Socket网络编程,假设读者已经具备了基本的网络编程知识和Python的基本语法知识,本文中的代码如果没有说明则都是运行在 ...
- dockerfile中设置环境变量
设置环境变量要用 ENV ENV JAVA_HOME /usr/local/jdk1.8.0_171 ENV PATH $JAVA_HOME/bin:$PATH 用 echo "JAVA_H ...
- [CareerCup] 9.8 Represent N Cents 组成N分钱
9.8 Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies ...
- 海思NB-IOT模组在平台上注册
1. 添加设备,网页测试平台 https://develop.ct10649.com:8093/#/applications/1_lq7clNExjnGvPvGMG8w7_oYn4a/products ...
- 系统调用system call以及strace/dtruss
计算机系统的各种硬件资源是有限的,在现代多任务操作系统上同时运行的多个进程都需要访问这些资源,进程是不允许直接操作这些资源的,所有对这些资源的访问都必须有操作系统控制.也就是说操作系统是使用这些资源的 ...
- AtCoder Beginner Contest 147 E. Balanced Path
思路: dp,使用了bitset优化. 实现: #include <bits/stdc++.h> using namespace std; ; const int INF = 0x3f3f ...
- jenkins最新版下载安装
前提:安装配置 jetty 在线下载jetty# wget http://download.eclipse.org/jetty/8.1.17.v20150415/dist/jetty-distribu ...
- linux本地内核提权之CVE-2019-13272(鸡肋)
CVE-2019-13272 发布时间: 2019月7月17日 影响内核版本: Linux Kernel < 5.1.17 漏洞描述: 译文 kernel 5.1.17之前版本中存在安全漏洞,该 ...
- layer.prompt添加多个输入框
原文链接:https://www.jianshu.com/p/65fea33e6750 我们都知道layer.prompt官网上的例子是一个弹出框,那么有没有可能出来多个呢,当然是可以的 1.首先增加 ...
- 个人PC电脑 关闭网卡自启
前言: 今早我打开我的电脑,惊呆了.出现了以下字样: This Product is covered by one or more of the following patents ... 看了BIO ...