基于heartbeat v2和heartbeat-ldirectord实现LVS(DR)中Director的高可用,基于httpd提供web服务,并通过hb_gui的图形界面进行;
规划
准备工作:三台主机, 分别配置如图所示的IP 和主机名
注意:1、rs1和rs2提供的不同的页面,目的是让效果明显
2 、VIP,即虚拟地址,不能被其他主机占用
3、director中的ipvsadm和vip都要确保是关闭的,让CRM来管理这些资源
一、配置LVS(DR)模型
rs1 #setenforce 0
//关闭selinux#yum -y install httpd # echo "<h1>rs1</h1>" >> /var/www/html/index.html //提供页面文件#service httpd start # echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore # echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore # echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce # echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce # ifconfig lo:0 172.16.220.100 broadcast 172.16.220.100 netmask 255.255.255.255 up # route add -host 172.16.220.100 dev lo:0 # elinks -dump
//测试 rs1 # elinks -dump rs1 rs2: #setenforce 0 # yum -y install httpd # echo "<h1>rs2</h1>" >> /var/www/html/index.html #service httpd start # echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore # echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore # echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce # echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce # ifconfig lo:0 172.16.220.100 broadcast 172.16.220.100 netmask 255.255.255.255 up # route add -host 172.16.220.100 dev lo:0 # elinks -dump rs2 # elinks -dump rs2 Directory :node1 #setenforce 0 # yum -y install ipvsadm
//安装ipvsam# ifconfig eth0:0 172.16.220.100 broadcast 172.16.220.100 netmask 255.255.255.255 up # route add -host 172.16.220.100 dev eth0:0 # echo 1 > /proc/sys/net/ipv4/ip_forward # ipvsadm -A -t 172.16.220.100:80 -s r # ipvsadm -a -t 172.16.220.100:80 -r 172.16.220.21 -g # ipvsadm -a -t 172.16.220.100:80 -r 172.16.220.22 -g # ipvsadm -ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 172.16.220.100:80 rr -> 172.16.220.22:80 Route 1 0 0 -> 172.16.220.21:80 Route 1 0 0 测试;172.16.220.100 效果是rs1 rs2的轮询
到此,一个LVS的DR模型创建成功了。