|
一、ipvsadm安装1,安装环境centos7.0内核3.10.0-327.el7.x86_64 。需安装gcc1
| [iyunv@localhost ~]# yum -y install gcc
|
未避免安装过程安全其他依赖,可在安装系统时选择如下几个组件:
2,下载ipvsadm安装包(下载1.27版本)https://kernel.org/pub/linux/utils/kernel/ipvsadm/
3,解压、编译、安装1
2
3
| [iyunv@localhost ~]# tar -Jxvf ipvsadm-1.27.tar.xz
[iyunv@localhost ~]# cd ipvsadm-1.27
[iyunv@localhost ipvsadm-1.27]# make && make install
|
4,可能出现如下错误:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| [iyunv@localhost ipvsadm-1.27]# make &make install
[1] 14264
make -C libipvs
make -C libipvs
make[1]: Entering directory`/root/ipvsadm-1.27/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g-fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -olibipvs.o libipvs.c
make[1]: Entering directory`/root/ipvsadm-1.27/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g-fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -olibipvs.o libipvs.c
In file included from libipvs.h:13:0,
from libipvs.c:23:
ip_vs.h:15:29: fatal error:netlink/netlink.h: No such file or directory
#include <netlink/netlink.h>
^
compilation terminated.
In file included from libipvs.h:13:0,
from libipvs.c:23:
ip_vs.h:15:29: fatal error:netlink/netlink.h: No such file or directory
#include <netlink/netlink.h>
^
compilation terminated.
make[1]: *** [libipvs.o] Error 1
make[1]: Leaving directory`/root/ipvsadm-1.27/libipvs'
make: *** [libs] Error 2
make[1]: *** [libipvs.o] Error 1
make[1]: Leaving directory`/root/ipvsadm-1.27/libipvs'
make: *** [libs] Error 2
[1]+ Exit 2 make
|
解决方法是安装如下软件:
1
2
| [iyunv@localhost ipvsadm-1.27]# yum installpopt-static
[iyunv@localhost ipvsadm-1.27]# yum installlibnl* libpopt*
|
二、keepalived安装1)软件下载(下载1.2.13版本)http://www.keepalived.org/software/
2)解压、配置、编译、安装1
2
3
4
| [iyunv@localhost ~]# tar -zxvf keepalived-1.2.13\ \(1\).tar.gz
[iyunv@localhost ~]# cd keepalived-1.2.13
[iyunv@localhost keepalived-1.2.13]#./configure --prefix=/usr/local/keepalived
[iyunv@localhost keepalived-1.2.13]# make && make install
|
3)编译时可能会出现如下错误11
2
3
| configure: error:
!!!OpenSSL is not properly installed on your system. !!!
!!!Can not include OpenSSL headers files. !!!
|
解决方法:
1
| [iyunv@localhost keepalived-1.2.13]# yuminstall -y openssl openssl-devel
|
4)编译过程可能会出现如下错误21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| [iyunv@localhost keepalived-1.2.13]# make
make -C lib || exit 1;
make[1]: Entering directory`/root/keepalived-1.2.13/lib'
gcc -g -O2 -DFALLBACK_LIBNL1 -I. -Wall-Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c command.c
make[1]: Leaving directory`/root/keepalived-1.2.13/lib'
make -C keepalived
make[1]: Entering directory`/root/keepalived-1.2.13/keepalived'
make[2]: Entering directory`/root/keepalived-1.2.13/keepalived/core'
gcc -g -O2 -DFALLBACK_LIBNL1 -I/usr/src/linux/include -I/usr/src/linux/include-I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_-D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITH_SO_MARK_ -c main.c
gcc -g -O2 -DFALLBACK_LIBNL1 -I/usr/src/linux/include-I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused-Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_-D_WITH_SO_MARK_ -c smtp.c
In file included from/usr/include/linux/if_addr.h:4:0,
from../include/vrrp_ipaddress.h:33,
from ../include/vrrp.h:31,
from ../include/smtp.h:34,
from smtp.c:27:
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
/usr/src/linux/include/linux/linkage.h:7:25:fatal error: asm/linkage.h: No such file or directory
#include <asm/linkage.h>
^
compilation terminated.
make[2]: *** [smtp.o] Error 1
make[2]: Leaving directory`/root/keepalived-1.2.13/keepalived/core'
make[1]: *** [all] Error 1
make[1]: Leaving directory`/root/keepalived-1.2.13/keepalived'
make: *** [all] Error 2
|
解决方法:
去掉如下符号链接(之前配置符号链接ln -s /usr/src/kernels/3.10.0-229.el7.x86_64/ /usr/src/linux)
1
| [iyunv@localhost keepalived-1.2.13]# rm -rf /usr/src/linux
|
5)配置1
2
3
4
5
| [iyunv@localhost keepalived]#cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/
[iyunv@localhost keepalived]#cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
[iyunv@localhost keepalived]#mkdir /etc/keepalived
[iyunv@localhost keepalived]#cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
[iyunv@localhost keepalived]#cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
|
6)修改配置文件/etc/keepalived/keepalived.conf
7)启动服务并开启开机自启动1
2
3
| [iyunv@localhost keepalived]# service keepalived
Usage: /etc/init.d/keepalived{start|stop|reload|restart|condrestart|status}
[iyunv@localhost keepalived]# chkconfig keepalived on
|
8)启动可能出现如下错误31
2
3
4
5
6
7
8
9
10
11
12
13
14
| [iyunv@localhost ~]# service keepalived status
keepalived.service - SYSV:Start and stop Keepalived
Loaded: loaded (/etc/rc.d/init.d/keepalived)
Active: failed (Result: exit-code) since Wed 2016-08-31 07:22:19 EDT;5min ago
Docs: man:systemd-sysv-generator(8)
Process: 2405 ExecStart=/etc/rc.d/init.d/keepalived start (code=exited,status=1/FAILURE)
Aug 31 07:22:19 localhost.localdomainsystemd[1]: Starting SYSV: Start and stop Keepalived...
Aug 31 07:22:19 localhost.localdomainkeepalived[2405]: Starting keepalived: /bin/bash: keepalived: command not found
Aug 31 07:22:19 localhost.localdomainkeepalived[2405]: [FAILED]
Aug 31 07:22:19 localhost.localdomainsystemd[1]: keepalived.service: control process exited, code=exited status=1
Aug 31 07:22:19 localhost.localdomainsystemd[1]: Failed to start SYSV: Start and stop Keepalived.
Aug 31 07:22:19 localhost.localdomainsystemd[1]: Unit keepalived.service entered failed state.
Aug 31 07:22:19 localhost.localdomainsystemd[1]: keepalived.service failed.
|
解决方法:
1
| [iyunv@localhost ~]# ln -s/usr/local/keepalived/sbin/keepalived /usr/sbin/
|
其中/usr/local/keepalived/为软件安装目录。
|
|