LVS-DR模式下(RS检测)ldirectord工具实现部分节点掉点后将请求发往正常设备进行处理

基于前文的LVS-DR集群构建环境

一.下载ldirectord软件

二.将模板文件中的LVS-DR模式相关文件拷贝到/etc/ha.d主配置目录并按实际设备修改

三.配置两台RS匹配规则

四.停止RS1的http服务进行测试

RS1失去工作能力,RS2接替RS1


基于前文的LVS-DR集群构建环境

一.下载ldirectord软件

复制代码
[root@localhost ~]# yum install -y ldirectord-4.1.1-3.40.el7.noarch.rpm
[root@localhost ~]# rpm -ql ldirectord
/etc/ha.d   #主配置目录
/etc/ha.d/conf
/etc/ha.d/resource.d
/etc/ha.d/resource.d/ldirectord
/etc/logrotate.d/ldirectord
/etc/rc.d/init.d/ldirectord
/run/ldirectord
/usr/lib/systemd/system/ldirectord.service   #服务管理
/usr/lib/tmpfiles.d/ldirectord.conf
/usr/sbin/ldirectord  #主程序
/usr/share/doc/ldirectord-4.1.1
/usr/share/doc/ldirectord-4.1.1/ldirectord.cf  #配置模板文件
/usr/share/man/man8/ldirectord.8.gz

二.将模板文件中的LVS-DR模式相关文件拷贝到/etc/ha.d主配置目录并按实际设备修改

复制代码
[root@localhost ha.d]# pwd
/etc/ha.d
[root@localhost ha.d]# vim ldirectord.cf 
checktimeout=3
checkinterval=1
autoreload=yes  #自动重载
logfile="/var/log/ldirectord.log"   #日志存放路径
quiescent=no

virtual=192.168.2.188:80   #VIP地址1
        servicename=Web Site
        comment=Test load balanced web site
        real=192.168.2.191:80 gate 2   #RS地址,gate表示权重1
        real=192.168.2.192:80 gate 3
        service=http  
        scheduler=wrr  #调度算法
        protocol=tcp  
        checktype=negotiate
        checkport=80
        request="index.html"
        receive="Test Page"
        virtualhost=www.x.y.z

三.配置两台RS匹配规则

复制代码
[root@localhost ha.d]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.2.188:80 wrr
[root@localhost ha.d]# ipvsadm -a -t 192.168.2.188:80 -r 192.168.2.191 -g -w 2
[root@localhost ha.d]# ipvsadm -a -t 192.168.2.188:80 -r 192.168.2.192 -g -w 3
[root@localhost ha.d]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  localhost.localdomain:http wrr
  -> 192.168.2.191:http           Route   2      0          0         
  -> 192.168.2.192:http           Route   3      0          0         

四.停止RS1的http服务进行测试

RS1失去工作能力,RS2接替RS1

复制代码
[root@localhost ~]# systemctl stop httpd.service
[root@localhost ~]# for ((i=1;i<=10;i++)); do curl 192.168.2.188:80; done
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
share192
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
share192
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
[root@localhost ~]# for ((i=1;i<=10;i++)); do curl 192.168.2.188:80; done
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
share192
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
share192
share192
curl: (7) Failed connect to 192.168.2.188:80; Connection refused
相关推荐
444A4E几秒前
深入Linux进程优先级:Nice值与O(1)调度器原理
linux·操作系统
Jooolin几秒前
【编程史】Git是如何诞生的?这可并非计划之中...
linux·git·ai编程
云边有个稻草人4 分钟前
【Linux系统】第八节—进程概念(上)—冯诺依曼体系结构+操作系统+进程及进程状态+僵尸进程—详解!
linux·进程·冯诺依曼体系结构·pcb·僵尸进程·进程的状态·task_ struct
xian0gang14 分钟前
rk3588 区分两个相同的usb相机
linux
这儿有一堆花24 分钟前
安全访问家中 Linux 服务器的远程方案 —— 专为单用户场景设计
linux·服务器·安全
RussellFans1 小时前
Linux 文本三剑客(grep, awk, sed)
linux·运维·服务器
Chuncheng's blog1 小时前
CentOS 7如何编译安装升级gcc至7.5版本?
linux·运维·c++·centos
听风吹等浪起1 小时前
CentOS在vmware局域网内搭建DHCP服务器【踩坑记录】
linux·服务器·centos
明月看潮生1 小时前
青少年编程与数学 01-011 系统软件简介 04 Linux操作系统
linux·青少年编程·操作系统·系统软件·编程与数学
aitav02 小时前
⚡️ Linux Docker 基本命令参数详解
linux·运维·docker