用Keepalived搭建双Nginx server集群,防止单点故障
综述:
浏览器访问虚拟IP: 192.168.1.57, 该虚拟IP被Keepalived接管,两个Keepalived进程分别运行在物理IP为192.168.1.56和192.168.1.59服务器上,这两个服务器上都运行着Nginx server。Nginx server都监听虚拟IP 192.168.1.57. Nginx背后有一些web app集群,已经配置成upstream.
为了防止Nginx自己成为单点瓶颈,这里采用了双Nginx server的方式。每个Server都是Ubuntu 12.04.
假定我的第一台Ubuntu server物理IP地址是192.168.1.56,已经安装了Nginx server,现在安装Keepalived,后面称这台为master server.
vrrp_instance VI_1 { interface eth0 state BACKUP // changed priority 100 // changed
通过轮流关闭master和backup,证明keepalived已经有效工作了。
参考资料:Keepalived官方文档真是够差的。
http://www.leaseweblabs.com/2011/09/setting-up-keepalived-on-ubuntu-load-balancing-using-haproxy-on-ubuntu-part-2/
http://blog.csdn.net/zmj_88888888/article/details/8825471