Linux下Keepalived 安装与配置

Posted 进化史

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下Keepalived 安装与配置相关的知识,希望对你有一定的参考价值。

一、环境说明

 

1、操作系统内核版本:2.6.9-78.ELsmp

    2Keepalived软件版本:keepalived-1.1.20.tar.gz

 

二、环境配置

 

1、主Keepalived服务器IP地址 192.168.111.223

2、备Keepalived服务器IP地址  192.168.111.100

3Keepalived虚拟IP地址  192.168.111.150

 

三、软件下载地址

 

      http://www.keepalived.org/software/keepalived-1.1.20.tar.gz

 

四、安装流程

 

   1、上传Keepalived/home/目录

    2、解压Keepalived软件

      [[email protected] home]# tar -zxvf keepalived-1.1.20.tar.gz 

      [[email protected] home]# cd keepalived-1.1.20

      [[email protected] keepalived-1.1.20]# ln -s /usr/src/kernels/2.6.9-78.EL-i686/usr/src//linux

      [[email protected] keepalived-1.1.20]# ./configure 

 

  遇到错误提示:configure: error: Popt libraries is required

  这个错误是因为没有安装popt的开发包导致的,解决方法也很简单,只要yum install popt-devel 就可以安装好popt的开发包了。

  重新./configure

  没有遇到跳过这一步

   3、提示

          技术分享

   4、编译以及编译安装

      [[email protected] keepalived-1.1.20]# make && make install

技术分享

      5、将types.h调用的部分注释掉即可解决4出现的问题

     vi/usr/src/kernels/2.6.9-78.EL-i686/include/linux/types.h 

     到158行操作如下

     

   #endif 

    

    

 6、重新编译以及编译安装

     [[email protected] keepalived-1.1.20]# make && make install

       技术分享

   

   7修改配置文件路径

       [[email protected]]#cp/usr/local/etc/rc.d/init.d/keepalived/etc/rc.d/init.d/

       [[email protected]]# cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

       [[email protected] keepalived-1.1.20]# mkdir /etc/keepalived

       [[email protected]]#cp /usr/local/etc/keepalived/keepalived.conf/etc/keepalived/                           

       [[email protected] keepalived-1.1.20]# cp /usr/local/sbin/keepalived /usr/sbin/

   8、设置为服务,开机启动

       [[email protected] keepalived-1.1.20]# vi /etc/rc.local 

       技术分享



 

五、主Keepalived配置

 

     1、修改配置文件

        [[email protected] 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

以上是关于Linux下Keepalived 安装与配置的主要内容,如果未能解决你的问题,请参考以下文章

keepalived安装与配置

keepalived安装与配置,组建高可用服务器

Keepalived安装与配置

Keepalived安装与配置

Keepalived安装与配置

Linux下 keepalived 的安装和配置