配置server4,ip 为172.25.77.4
1.首先将keepalived的压缩包进行解压
2.从网上获取libnfnetlink-devel-1.0.0-1.el6.x86_64.rpm安装包,并进行如下操作。
yum install openssl-devel libnfnetlink-devel-1.0.0-1.el6.x86_64.rpm -y
yum install gcc-c++ -y
cd /root/keepalived
./configure --prefix=/usr/local/keepalived --with-init=SYSV
make && make install
ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /usr/local/keepalived/etc/keepalived/ /etc/
ln -s /usr/local/keepalived/sbin/keepalived /bin/
chmod +x /usr/local/keepalived/etc/rc.d/init.d/keepalived
scp -r keepalived/ 172.25.77.4:/usr/local/
ip addr del 172.25.77.100/24 dev eth0
/etc/init.d/ldirectord stop
chkconfig ldirectord off
yum install mail -y
4.在server4上进行查看
进行如下操作
ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /usr/local/keepalived/etc/keepalived/ /etc/
ln -s /usr/local/keepalived/sbin/keepalived /bin/
chmod +x /usr/local/keepalived/etc/rc.d/init.d/keepalived
5.更改server1上的keepalived配置,并发送给server4
yum install ipvsadm -y
/etc/init.d ipvsadm start
vim /etc/keepalived/keepalived.conf
/etc/init.d/keepalived start
scp keepalived.conf 172.25.77.4:/etc/keepalived
6.更改server4上的keepalived配置文件
yum install ipvsadm -y
/etc/init.d ipvsadm start
vim /etc/keepalived/keepalived.conf
其他都和server1配置一样,但是要将12行注释掉,20行改为
state BACKUP
/etc/init.d/keepalived restart
7.此时在server1上查看ip addr,vip绑定在server1上
在server1上执行ifdown eth0
,vip会漂移到server4上
在server1上执行ifup eth0
,server4上执行ifdown eth0
vip 又会从server4上漂移到server1上。
8.