LVS-DR模式
1.原理图:
2.实验图:
(1)环境描述:centos7.2
(2)关闭系统防火墙
systemctl stop firewalld.service
部署步骤:
配置Directory服务器:
一、检查系统是否支持ip_vs
modprobe ip_vs 加载ip_vs模块
lsmod |grep ip_vs 查询模块
二、配置DIP和VIP:
DIP正常配置网卡,地址为:192.168.100.6
ifconfig eno16777736:0 192.168.100.7 netmask 255.255.255.255 broadcast 192.168.100.7
三、安装并配置ipvsadm集群管理工具:
(1) yum install ipvsadm -y
添加集群服务
(2)ipvsadm -A -t 192.168.100.7:80 -s rr
ipvsadm -a -t 192.168.100.7:80 -r 192.168.100.11 -g -w 1
ipvsadm -a -t 192.168.100.7:80 -r 192.168.100.12 -g -w 1
查询集群服务:
ipvsadm -Ln
配置RS服务器:
一、禁止arp响应脚本
bash set.sh start
#! /bin/bash
case $1 in
start)
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/eno16777736/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/eno16777736/arp_announce
;;
stop)
echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/eno16777736/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/eno16777736/arp_announce
;;
esac
二、添加路由及配置lo:0接口
ifconfig lo:0 192.168.100.7 netmask 255.255.255.255 broadcast 192.168.100.7
route add -host 192.168.100.7 dev lo:0
三、安装并启动web服务
yum install httpd -y
systemctl start httpd.service
echo "RS1" >>/var/www/html/index.html
客户端验证:
ipvsadm查询轮询