RHEL5.5下的Keepalived编译安装

keepalived简介
keepalived是一个类似于layer3, 4 & 5交换机制的软件,也就是我们平时说的第3层、第4层和第5层交换。Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的web服务器从系统中剔除,当web服务器工作正常后Keepalived自动将web服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的web服务器。
keepalived下载:
下载地址:http://www.keepalived.org/download.html 可以选择需要的版本。
 wget http://www.keepalived.org/software/keepalived-1.2.1.tar.gz

实验环境
两台Redhat Linux RHEL 5.5:

在安装前需要安装kernel-devel 、libnl-devel、popt-devel依赖包

解压keepalived-1.2.1.tar到/usr/src

cd /usr/src/keepalived-1.2.1
./configure --prefix=/usr/local/keepalived

检查keepalived编译与内核结合,调用ipvs成功:有以下信息

如没有以下信息,使用如下方法:

A、换个keepalived版本安装

B、指定内核来安装,

cd /usr/src/keepalived-1.2.1

./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.18-408.el5-i686

注:/usr/src/kernels/2.6.18-408.el5-i686由yum install -y kernel-devel安装而来。

就会有以下配置信息

Keepalived configuration
------------------------
Keepalived version       : 1.2.1
Compiler                 : gcc
Compiler flags           : -g -O2
Extra Lib                : -lpopt -lssl -lcrypto
Use IPVS Framework       : Yes
IPVS sync daemon support : Yes
Use VRRP Framework       : Yes

Use LinkWatch            : No
Use Debug flags          : No

才能进行下一步,否则ipvsadm -ln无法查看lvs信息

make
make install

不出意外,安装过程就完毕了,设置成系统服务启动运行:
可以看到/usr/local/keepalived下面有几个文件,我们需要复制一些文件到其他文件夹里面,下面为操作方法:
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived
cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/keepalived/sbin/keepalived /usr/sbin/

添加系统服务开机启动:

chkconfig --add keepalived

chkconfig --level 345 keepalived on

手动启动或停止服务是service keepalived start|stop|restart
 接下来是配置conf文件,只有配置/etc/keepalived/keepalived.conf才生效。


参考资料:***linux/anzhuangkeepalivedyudaoproblem_60936_1359451872.html

                 http://www.wenkuxiazai.com/doc/a585ffcd89eb172ded63b7bc-2.html

                 http://400053.blog.51cto.com/390053/713566
                 http://blog.csdn.net/huangxy10/article/details/9903479

你可能感兴趣的:(keepalived,RHEL,5.5)