Keepalived源码安装

      Keepalived的功能很强大,主要检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工作正常后Keepalived自动将服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的服务器。在这里我就不详细介绍了  

接下来我们直接下载包直接安装

1、keepalived安装。

先安装keepalived依赖组件

[root@node3 ~]#yum -y install libnl libnl-devel libnfnetlink-devel popt-devel  gcc make

进入一个目录,我这里为了方便直接到src目录下

[root@node3 ~]# cd /usr/local/src/	

#下载keepalived压缩包

[root@node3 src]# wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

 

#解压并把解压完的文件指向存放位置

[root@node3 src]#tar zxvf keepalived-1.2.7.tar.gz  -C  /usr/local
[root@node3 src]#cd ../keepalived-1.2.7

#编译

[root@node3 keepalived-1.2.7]#./configure

#编译成功结果如下:

Keepalived configuration 
------------------------ 
Keepalived version       : 1.2.7 
Compiler                 : gcc 
Compiler flags           : -g -O2 
Extra Lib                : -lpopt -lssl -lcrypto  -lnl 
Use IPVS Framework       : Yes 
IPVS sync daemon support : Yes 
IPVS use libnl           : Yes 
Use VRRP Framework       : Yes 
Use VRRP VMAC            : Yes 
SNMP support             : No 
Use Debug flags          : No
[root@node3 keepalived-1.2.7]# make && make install

#把 keepalived的启动文件复制到init.d下,加入开机启动项

[root@node3 keepalived-1.2.7]#cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/

#将keepalived文件拷贝到etc下

[root@node3 keepalived-1.2.7]#cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

#创建keepalived文件夹

[root@node3 keepalived-1.2.7]#mkdir /etc/keepalived

#将keepalived配置文件拷贝到etc/keepalived下 

[root@node3 keepalived-1.2.7]#cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

#把keepalived加入系统命令目录

[root@node3 keepalived-1.2.7]#cp /usr/local/sbin/keepalived /usr/sbin/

#到这里源码安装Keepalived就已经完成了。接下来就可以愉快的用了