俩主一备主机down备机顶上
vip : 192.168.199.120
rip : 192.168.199.110
192.168.199.111
调度器安装:
1、关闭防火墙
2、安装ipvsadm
yum install ipvsadm -y
3、添加表
ipvsadm -A -t 192.168.199.120:80 -s rr
添加记录(调度的对象,web)
ipvsadm -a -t 192.168.199.120:80 -r 192.168.199.110
ipvsadm -a -t 192.168.199.120:80 -r 192.168.199.111
4、设置vip地址
ifconfig ens33:1 192.168.199.120/32

route add -host 192.168.199.120 dev ens33:1

echo 1 > /proc/sys/net/ipv4/ip_forward

两台Web 服务上配置安装
mkdir -p /data/server
个人写了一个web服务器脚本
+++++++++++++++++++++++++++++++++++++++
#!/bin/bash
yum -y install openssl openssl-devel zlib zlib-devel pcre pcre-devel
yum -y install gcc
yum -y install gcc-c++

wget http://nginx.org/download/nginx-1.16.0.tar.gz
tar -zxvf nginx-1.16.0.tar.gz

cd nginx-1.16.0
./configure --prefix=/data/server/nginx
make && make install
cd /data/server/nginx/sbin
./nginx -t
./nginx
++++++++++++++++++++++++++++++++++++++++++++++
安装好了可以编辑web服务器的网页两台添加不一样的

执行完脚本两台realserver 关闭防火墙
systemctl stop firewalld
setenforce 0

虚拟隐藏VIP

echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

在lo上设置VIP地址
ifconfig lo:0 192.168.199.120/32
添加路由
route add -host 192.168.199.120 dev lo:0

调度器
ipvsadm -Ln

访问vip访问哪台成功了就关闭哪台web服务器,再次刷新,如果刷新出另外一台web服务器,DR模式就搭建成功了