一、环境说明
1、操作系统内核版本:linux 6.0
2、Keepalived软件版本:keepalived-1.1.20.tar.gz
二、环境配置
1、主Keepalived服务器IP地址 192.168.111.223
2、备Keepalived服务器IP地址 192.168.111.100
3、Keepalived虚拟IP地址 192.168.111.150
三、软件下载地址
http://www.keepalived.org/software/keepalived-1.1.20.tar.gz
四、安装流程
1、上传Keepalived至/home/目录
2、解压Keepalived软件
[root@localhost home]# tar -zxvf keepalived-1.1.20.tar.gz
[root@localhost home]# cd keepalived-1.1.20
[root@localhost keepalived-1.1.20]# ln -s /usr/src/kernels/2.6.9-78.EL-i686/usr/src//linux
[root@localhost keepalived-1.1.20]# ./configure
在遇到错误提示时:configure: error: Popt libraries is required
这个错误发球胜的原理是由于因为没有安装popt的开发包导致的,只要yum install popt-devel 就可以安装好popt的开发包了。
重新./configure即可
4、编译以及编译安装
root@localhost keepalived-1.1.20]# make && make install
当出现编译和暗转问题时,可以将types.h调用的部分注释掉即可解决4出现的问题
vi/usr/src/kernels/2.6.9-78.EL-i686/include/linux/types.h
#endif
5、修改配置文件路径
[root@localhostkeepalived-1.1.20]#cp/usr/local/etc/rc.d/init.d/keepalived/etc/rc.d/init.d/
[root@localhostkeepalived-1.1.20]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/
[root@localhost keepalived-1.1.20]# mkdir /etc/keepalived
[root@localhostkeepalived-1.1.20]#cp /usr/local/etc/keepalived/keepalived.conf/etc/keepalived/
[root@localhost keepalived-1.1.20]# cp /usr/local/sbin/keepalived /usr/sbin/
6、设置为服务,开机启动
[root@localhost keepalived-1.1.20]# vi /etc/rc.local
五、主Keepalived配置
1、修改配置文件
[root@localhost keepalived-1.1.20]# vi /etc/keepalived/keepalived.conf
六、备Keepalived配置
1、修改配置文件和启动服务
八、查看网卡信息
1、主Keepalived网卡信息
九、验证测试
1、在主服务器上新建一个网页,内容为 192.168.111.223
2、在备用服务器上新建一个网页,内容为 192.168.111.100
3、启动主备服务器的http服务和Keepalived服务
4、通过浏览数,输入虚拟IP地址 192.168.111.150
页面显示为 192.168.111.223
5、关闭主服务器的Keepalived服务,通过浏览器输入IP地址192.168.111.150
页面显示为 192.168.111.100
6、再次启动主服务器的Keepalived服务,通过浏览器输入IP地址192.168.111.150
页面显示为 192.168.111.223
本实验主要来源于https://www.cnblogs.com/dcrq/p/5642680.html,同时借鉴配置完成