tar zxvf keepalived-1.1.19.tar.gz
cd keepalived-1.1.19
./configure --prefix=/opt/keepalived && make && make install
cp keepalived/etc/init.d/keepalived.sysconfig /etc/sysconfig/keepalived
cp keepalived/etc/init.d/keepalived.rh.init /etc/init.d/keepalived
chmod +x /etc/init.d/keepalived
ln -s /opt/keepalived/sbin/keepalived /sbin/keepalived
chkconfig --add keepalived
cp -a keepalived/etc/keepalived/ /etc/
编辑keepalived.conf
vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id bj_ifc_ngix
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 314159
}
virtual_ipaddress {
192.168.1.253
}
state 2个都写成backup 让2台机器通过priority的优先级去抢主 ,优先级高的是主,最下面的IP我设定的是和eth0IP一个网段的,通过service keepalived start 启动服务,直接ping 253,如果通,那证明虚拟IP成功。
阅读(2599) | 评论(0) | 转发(0) |