tar -zxvf keepalived-2.2.0.tar.gz cd keepalived-2.2.0
./configure --prefix=/application/keepalived-2.2.0 [ 下方有编译不通过解决方案 ]
make && make install
mkdir /etc/keepalived/
cp /usr/local/keepalived-2.2.0/keepalived/etc/init.d/keepalived /etc/init.d/
mkdir /etc/sysconfig
cp /usr/local/keepalived-2.2.0/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
cp /usr/local/keepalived-2.2.0/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ service keepalived start systemctl status keepalived
配置文件
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
root@director_server
}
notification_email_from root@director_server
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
# vrrp_strict
# vrrp_garp_interval 0
# vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER
interface 网卡名称
virtual_router_id 51
priority 100
advert_int 1
nopreempt
authentication {
auth_type PASS
auth_pass 1111
}
}
virtual_ipaddress {
其他机器IP
}
1.系统出现警告信息 “
checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... configure: error: newly created file is older than distributed files! Check your system clock
”此报错是由于系统时间与硬件时间不一致导致的。
linux系统的时间分为系统时间 和 硬件时间。 硬件时间 就是指RTC中的时间,hwclock命令就是对这个时间操作。 系统时间 是系统开机时读取硬件时间作为系统的时间,此后系统时钟独立运作,在系统关机时再将系统时间写回RTC。
date命令只操作系统时间,hwclock操作硬件时钟,在date 修改时间后 最好用hwclock 同步一下,以免系统非正常关机造成时间不同步。
[root@Web01 src]# date Sun Mar 19 09:35:08 CST 2017 [root@Web01 src]# hwclock Tue 03 Jul 2018 10:19:17 PM CST -0.458468 seconds
同步时间,写入CMOS:
[root@Web01 src]# ntpdate ntp1.aliyun.com 3 Jul 14:28:12 ntpdate[79878]: step time server 120.25.115.20 offset 40711428.938760 sec [root@Web01 src]# date Tue Jul 3 14:28:19 CST 2018 [root@Web01 src]# hwclock Tue 03 Jul 2018 10:28:23 PM CST -0.860282 seconds [root@Web01 src]# hwclock Tue 03 Jul 2018 10:28:36 PM CST -0.641474 seconds问题解决!!!!
2. 系统出现警告信息
!!! OpenSSL is not properly installed on your system. !!! !!! Can not include OpenSSL headers files. !!!
解决方法:
[root@Web01 keepalived-2.0.0]# yum install -y openssl openssl-devel apt版 apt-get install openssl apt-get install libssl-dev
3. 系统出现警告信息
“*** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.”,具体日志如下:
Keepalived configuration ------------------------ Keepalived version : 2.0.0 Compiler : gcc Preprocessor flags : Compiler flags : -Wall -Wunused -Wstrict-prototypes -Wextra -Winit-self -g -O2 -D_GNU_SOURCE -fPIE -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 Linker flags : -pie Extra Lib : -lcrypto -lssl Use IPVS Framework : Yes IPVS use libnl : No IPVS syncd attributes : No IPVS 64 bit stats : No fwmark socket support : Yes Use VRRP Framework : Yes Use VRRP VMAC : Yes Use VRRP authentication : Yes With ip rules/routes : Yes Use BFD Framework : No SNMP vrrp support : No SNMP checker support : No SNMP RFCv2 support : No SNMP RFCv3 support : No DBUS support : No SHA1 support : No Use Json output : No libnl version : None Use IPv4 devconf : No Use libiptc : No Use libipset : No init type : upstart Build genhash : Yes Build documentation : No *** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.
解决方法:执行yum命令yum -y install libnl libnl-devel解决上述警告问题
[root@Web01 keepalived-2.0.0]# yum -y install libnl libnl-devel apt版本 apt-get install libnl-3-dev apt-get install libnl-genl-3-dev apt-get install libnl-3-200
4. 系统出现错误信息
“configure: error: libnfnetlink headers missing”,具体日志如下:
checking for nl_socket_modify_cb in -lnl... yes checking for linux/rtnetlink.h... yes checking libnfnetlink/libnfnetlink.h usability... no checking libnfnetlink/libnfnetlink.h presence... no checking for libnfnetlink/libnfnetlink.h... no configure: error: libnfnetlink headers missing
解决方法: yum install -y libnfnetlink-devel apt 下载源码包安装 安装完成以后,重新执行configure命令