安装环境
软件包keeplived.1.2.1
Master 10.0.67.51
slave 10.0.67.52
VIP 10.10.67.200 [master,slave]
安装步骤
打补丁yum install popt-devel -y
tar zxvf /opt/www/soft/keeplived.1.2.1.tar
cd keeplived-1.2.1
./configure
--sysconf=/etc
--prefix=/opt/keepalived
make && make install
安装完成后执行一下操作添加系统服务和开机启动项
cp /opt/keeplived/sbin/keeplived /usr/sbin/
chkconfig --add keeplived
chkconfig keeplived on
查看启动keeplived
/etc/init.d/keeplived status
/etc/init.d/keeplived start
keeplived配置文件位置是/etc/keeplived/keeplived.conf
master配置文件内容如下
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
mcast_src_ip 10.0.67.51
# 该机的 priority(优先) 为 100
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111222
}
virtual_ipaddress {
10.0.67.200
}
}
slave配置文件内容如下
vrrp_instance VI_1 {
state SLAVER
interface eth0
virtual_router_id 51
mcast_src_ip 10.0.67.52
# 该机的 priority(优先) 为 99
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111222
}
virtual_ipaddress {
10.0.67.200
}
}
验证
1在master主机上执行ip 命令 是否显示VIP10.0.67.200
ping 10.0.67.200是否ping通
2把master上的keeplived down掉,查看slave主机上是否获得VIP10.0.67.200
如获取vip 代表成功