在迁移haproxy负载的时候出现keepalived切换失败
具体故障现象如下:
两台haproxy+keepalived启动完毕,第一次访问到主机(正常)
killall keepalived ,删除主机的keepalived,马上切换到备机(正常,可以通过ip addr查看虚IP是否生效)
keepalived -f /usr/local/etc/keepalived/keepalived.conf ,启动主机的keepalived,正常应该切换回主机(失败),这时出现站点打不开的情况
在备机上用ip addr 查看,虚IP还是显示在那里
ps -e | grep keepalived #只有两个进程。正常情况下应该有3个keepalived的进程才对
解决keepalived只有两个进程的情况
只有两个进程,是因为当前的linux系统未指定内核位置cd /usr/src/kernels #发现这个目录下没有文件
yum install kernel -y
yum install kernel-devel -y
ln -s /usr/src/kernels/2.6.18-274.3.1.el5-i686/ /usr/src/linux #创建链接文档
然后重新编译安装keepalived
刚开始编译的是keepalived-1.2.2版本,出现/usr/include/stdint.h:41: error: conflicting types for ‘int64_t’
/usr/src/linux/include/linux/types.h:126: error: previous declaration of ‘int64_t’ was here
/usr/include/stdint.h:56: error: conflicting types for ‘uint64_t’
/usr/src/linux/include/linux/types.h:124: error: previous declaration of ‘uint64_t’ was here
In file included from /usr/include/stdlib.h:438,
等错误
不得解,后选择keepalived-1.1.9版本,编译不报错
安装后查看 ps -e|grep keepalived 有三个进程在跑
解决安装keepalived-1.2.2版本编译报错的问题vim keepalived/libipvs-2.6/ip_vs.h
把 #include 移动到 #include 的下面