主nginx负载均衡器:192.168.0.10
辅nginx负载均衡器:192.168.9.20
vip:192.168.0.100
cd keepalived-1.1.17
./configure –prefix=/usr/local/keepalive
make ; make install
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
mkdir /etc/keepalived
vim /etc/keepalived/keepalived.conf
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
#backup ipaddress
mcast_src_ip 192.168.0.20
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass ufsoft
}
virtual_ipaddress {
192.168.0.100
}
}
mkdir /etc/keepalived
vim /etc/keepalived/keepalived.conf
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
#master ipaddress
mcast_src_ip 192.168.0.10
priority 50
advert_int 1
authentication {
auth_type PASS
auth_pass ufsoft
}
virtual_ipaddress {
192.168.0.100
}
}
启动keepalived:
keepalived -f /etc/keepalived/keepalived.conf -D
//-f指定了keepalived的配置文件位置
三、nginx部署