LVS双机热备和负载均衡一体化安装方法

heartbeat  以心跳机制监控实体主机是否存活,实现ipvsadm和ldirectord服务的故障转移。
ldirectord 可用来監控实体主機的服務进程是否正常,以决定在ipvsadm配置中删除或加入。

在本案例中,将使用CentOS6系统来安装传统的heartbeat+ldirector以实现双机热备的功能,因为RHEL均已经移除相关套件,所以安装比较麻烦一点,但只要一步一步做下来,其实也并不是太困难,而且还能够学习到很多东西。

另外请注意,因为本案例中将DR主机和RS主机合并在一起以节省IT资源,因此本案例只适合部署于同一子网内的主机(因为虚拟的VIP不能改变),也因此之故,ipvsadm也就可选择使用Director Routing 模式。

________
                       |        |
                       | client |
                       |________|
                           |
             CIP->VIP |    |   ^ 
                      v    |   | VIP->CIP
                           |
          ------------------------------------
          |                                  |
          |                                  |
  RIP1=192.168.57.101             RIP2=192.168.57.102 (eth0)
  VIP =192.168.57.200             VIP =192.168.57.200 (eth0:0, arps)
  VIP =192.168.57.200             VIP =192.168.57.200 (all lo:0,non-arping)
    _____________                      _____________
   |             |                    |             |
   | Director1 + |                    | Director2 + |
   | RealServer1 |                    | RealServer2 |
   |_____________|                    |_____________|


nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
调试应注意的情况:
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
另外,调试中要注意一个情况,ipvsadm所添加的规则应用于内核的路由,优先于其他网络
服务。举个例子来说,比如某IP的端口80被ipsvadm设置为转发,而同时本机又有HTTPD服务
使用此IP的80端口,那么ipvsadm规则将应用在先,而其他IP的端口80的服务则不受影响。


nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
注意ARP地址的更新:
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
因为我使用虚拟主机进行测试,所以ARP地址需要手动更新,否则测试会停留在旧地址上:
# arping -I vboxnet1 192.168.57.200;

一般LINUX系统预设的ARP缓存timeout时间是60秒,如有需要,您可以调整此内核参数:
# cat /proc/sys/net/ipv4/neigh/vboxnet1/gc_stale_time
# echo 5 > /proc/sys/net/ipv4/neigh/vboxnet1/gc_stale_time

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/7eef666ebd6390530c60ae5a13268b4d.html