安装前检查了ipvsadm、popt-devel、openssl-devel、libnfnetlink-devel是否存在,结果如下:

 keepalive编译安装 随笔

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

libnfnetlink-devel安装的是libnfnetlink。

Package ipvsadm-1.26-2.el6.x86_64 already installed and latest version

执行编译:

[root@abc keepalived-2.0.6]# 
[root@abc keepalived-2.0.6]# ./configure --prefix=/use/local/keepalived
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/vie61jiexiang/lwj/keepalived-2.0.6':
configure: error: C compiler cannot create executables
See `config.log' for more details
[root@abc keepalived-2.0.6]# 
[root@abc keepalived-2.0.6]#

报错了,查看日志:

[root@abc keepalived-2.0.6]# more config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by Keepalived configure 2.0.6, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure --prefix=/use/local/keepalived

## --------- ##
## Platform. ##
## --------- ##

hostname = i-33D24D56
uname -m = x86_64
uname -r = 2.6.32-431.el6.x86_64
uname -s = Linux
uname -v = #1 SMP Sun Nov 10 22:19:54 EST 2013

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2711: checking for a BSD-compatible install
configure:2779: result: /usr/bin/install -c
configure:2790: checking whether build environment is sane
configure:2845: result: yes
configure:2996: checking for a thread-safe mkdir -p
configure:3035: result: /bin/mkdir -p
configure:3042: checking for gawk
configure:3058: found /bin/gawk
configure:3069: result: gawk
configure:3080: checking whether make sets $(MAKE)
configure:3102: result: yes
configure:3131: checking whether make supports nested variables
configure:3148: result: yes
configure:3302: checking whether make supports nested variables
configure:3319: result: yes
configure:3385: checking for pkg-config
configure:3403: found /usr/bin/pkg-config
configure:3415: result: /usr/bin/pkg-config
configure:3440: checking pkg-config is at least version 0.9.0
configure:3443: result: yes
configure:3768: checking for gcc
configure:3784: found /usr/local/bin/gcc
configure:3795: result: gcc
configure:4024: checking for C compiler version
configure:4033: gcc --version >&5
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:4044: $? = 0
configure:4033: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/usr/local/ --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 7.3.0 (GCC) 
configure:4044: $? = 0
configure:4033: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:4044: $? = 1
configure:4033: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:4044: $? = 1
configure:4064: checking whether the C compiler works
configure:4086: gcc    conftest.c  >&5
/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/cc1: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory
configure:4090: $? = 1
configure:4128: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Keepalived"
| #define PACKAGE_TARNAME "keepalived"
| #define PACKAGE_VERSION "2.0.6"
| #define PACKAGE_STRING "Keepalived 2.0.6"
| #define PACKAGE_BUGREPORT "keepalived-devel@lists.sourceforge.net"
| #define PACKAGE_URL "http://www.keepalived.org/"
| #define PACKAGE "keepalived"
| #define VERSION "2.0.6"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:4133: error: in `/home/vie61jiexiang/lwj/keepalived-2.0.6':
configure:4135: error: C compiler cannot create executables
See `config.log' for more details

 

然后检查gcc都是正常的:

[root@abc ~]# 
[root@abc ~]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
目标:x86_64-pc-linux-gnu
配置为:./configure --prefix=/usr/local/ --disable-multilib --enable-languages=c,c++
线程模型:posix
gcc 版本 7.3.0 (GCC) 
[root@abc ~]#

查找找不到的库,的确存在:

[root@abc ~]# find / -name libmpc*
/mnt/cdrom/Packages/libmpcdec-1.2.6-6.1.el6.i686.rpm
/mnt/cdrom/Packages/libmpcdec-1.2.6-6.1.el6.x86_64.rpm
/usr/local/lib/libmpc.a
/usr/local/lib/libmpc.so.3.1.0
/usr/local/lib/libmpc.so.3
/usr/local/lib/libmpc.la
/usr/local/lib/libmpc.so
[root@abc ~]# 

没辙了,网上搜,找到了一篇博文:https://blog.csdn.net/qq_22790049/article/details/52873915

尝试加入临时环境变量:

[root@abc keepalived-2.0.6]# export LD_LIBRARY_PATH=/usr/local/lib/:.:$LD_LIBRARY_PATH

问题解决:

[root@abc keepalived-2.0.6]# ./configure --prefix=/use/local/keepalived
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for ranlib... ranlib
checking for grep that handles long lines and -e... /bin/grep
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for strip... strip
checking for ldd... ldd
checking for ar... ar
checking the archiver (ar) interface... ar
checking for -Wimplicit-fallthrough... yes
checking for PIE support... yes
checking for -Wformat -Werror=format-security support... yes
checking for -Wp,-D_FORTIFY_SOURCE=2 support... yes
checking for -fexceptions support... yes
checking for -fstack-protector-strong support... yes
checking for --param=ssp-buffer-size=4 support... yes
checking for -grecord-gcc-switches support... yes
checking for -Wl,-z,relro support... yes
checking for -Wl,-z,now support... yes
checking for -O2 support... yes
checking how to run the C preprocessor... gcc -E
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/prctl.h usability... yes
checking sys/prctl.h presence... yes
checking for sys/prctl.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for unistd.h... (cached) yes
checking for linux/netlink.h... yes
checking for linux/rtnetlink.h... yes
checking asm/types.h usability... yes
checking asm/types.h presence... yes
checking for asm/types.h... yes
checking linux/ethtool.h usability... yes
checking linux/ethtool.h presence... yes
checking for linux/ethtool.h... yes
checking linux/icmpv6.h usability... yes
checking linux/icmpv6.h presence... yes
checking for linux/icmpv6.h... yes
checking linux/if_ether.h usability... yes
checking linux/if_ether.h presence... yes
checking for linux/if_ether.h... yes
checking linux/if_packet.h usability... yes
checking linux/if_packet.h presence... yes
checking for linux/if_packet.h... yes
checking linux/ip.h usability... yes
checking linux/ip.h presence... yes
checking for linux/ip.h... yes
checking linux/sockios.h usability... yes
checking linux/sockios.h presence... yes
checking for linux/sockios.h... yes
checking linux/types.h usability... yes
checking linux/types.h presence... yes
checking for linux/types.h... yes
checking for linux/fib_rules.h... yes
checking for linux/if_addr.h... yes
checking for linux/if_link.h... yes
checking for linux/if_arp.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking for inline... inline
checking for int64_t... yes
checking for pid_t... yes
checking for size_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for uint8_t... yes
checking for an ANSI C-conforming const... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking for dup2... yes
checking for getcwd... yes
checking for gettimeofday... yes
checking for memmove... yes
checking for memset... yes
checking for select... yes
checking for setenv... yes
checking for socket... yes
checking for strcasecmp... yes
checking for strchr... yes
checking for strdup... yes
checking for strerror... yes
checking for strpbrk... yes
checking for strstr... yes
checking for strtol... yes
checking for strtoul... yes
checking for uname... yes
checking for pipe2... yes
checking for signalfd... yes
checking for inotify_init1... yes
checking for vsyslog... yes
checking whether ETHERTYPE_IPV6 is declared... yes
checking openssl/ssl.h usability... yes
checking openssl/ssl.h presence... yes
checking for openssl/ssl.h... yes
checking openssl/err.h usability... yes
checking openssl/err.h presence... yes
checking for openssl/err.h... yes
checking openssl/md5.h usability... yes
checking openssl/md5.h presence... yes
checking for openssl/md5.h... yes
checking for MD5_Init in -lcrypto... yes
checking for SSL_CTX_new in -lssl... yes
checking SSL_set_tlsext_host_name() - may be a definition... yes
checking for SSL_CTX_set_verify_depth... yes
checking for SSL_set0_rbio... no
checking for OPENSSL_init_crypto... no
checking for nl_socket_modify_cb in -lnl... no
configure: WARNING: keepalived will be built without libnl support.
checking for magic_open in -lmagic... no
checking whether RTA_ENCAP is declared... no
checking whether RTA_EXPIRES is declared... no
checking whether RTA_NEWDST is declared... no
checking whether RTA_PREF is declared... no
checking whether FRA_SUPPRESS_PREFIXLEN is declared... no
checking whether FRA_SUPPRESS_IFGROUP is declared... no
checking whether FRA_TUN_ID is declared... no
checking whether RTAX_CC_ALGO is declared... no
checking whether RTAX_QUICKACK is declared... no
checking whether RTEXT_FILTER_SKIP_STATS is declared... no
checking whether FRA_L3MDEV is declared... no
checking whether FRA_UID_RANGE is declared... no
checking whether RTAX_FASTOPEN_NO_COOKIE is declared... no
checking whether RTA_VIA is declared... no
checking whether FRA_OIFNAME is declared... no
checking whether FRA_PROTOCOL is declared... no
checking whether FRA_IP_PROTO is declared... no
checking whether FRA_SPORT_RANGE is declared... no
checking whether FRA_DPORT_RANGE is declared... no
checking whether IFA_FLAGS is declared... no
checking whether IP_MULTICAST_ALL is declared... no
checking whether LWTUNNEL_ENCAP_MPLS is declared... no
checking whether LWTUNNEL_ENCAP_ILA is declared... no
checking linux/netfilter/x_tables.h usability... yes
checking linux/netfilter/x_tables.h presence... yes
checking for linux/netfilter/x_tables.h... yes
checking xtables.h usability... no
checking xtables.h presence... no
checking for xtables.h... no
checking for linux/if.h and net/if.h namespace collision... yes
checking for linux/if_ether.h then netinet/if_ether.h namespace collision... no
checking for libiptc/libiptc.h linux/if.h and net/if.h namespace collision... yes
checking linux/ip_vs.h usability... yes
checking linux/ip_vs.h presence... yes
checking for linux/ip_vs.h... yes
checking whether IP_VS_SVC_F_ONEPACKET is declared... yes
checking whether IPVS_DEST_ATTR_ADDR_FAMILY is declared... no
checking whether IPVS_DAEMON_ATTR_SYNC_MAXLEN is declared... no
checking whether IPVS_DAEMON_ATTR_MCAST_GROUP is declared... no
checking whether IPVS_DAEMON_ATTR_MCAST_GROUP6 is declared... no
checking whether IPVS_DAEMON_ATTR_MCAST_PORT is declared... no
checking whether IPVS_DAEMON_ATTR_MCAST_TTL is declared... no
checking whether IPVS_SVC_ATTR_STATS64 is declared... no
checking whether IPVS_DEST_ATTR_STATS64 is declared... no
checking whether IFLA_MACVLAN_MODE is declared... yes
checking whether MACVLAN_MODE_PRIVATE is declared... yes
checking whether SOCK_NONBLOCK is declared... yes
checking whether SOCK_CLOEXEC is declared... yes
checking whether IPVS_SVC_ATTR_PE_NAME is declared... yes
checking whether O_PATH is declared... no
checking whether GLOB_BRACE is declared... yes
checking whether FRA_SRC is declared... yes
checking whether IFLA_INET6_ADDR_GEN_MODE is declared... no
checking whether SO_MARK is declared... yes
checking whether CLONE_NEWNET is declared... yes
checking for setns... no
checking whether SCHED_RR is declared... yes
checking whether RLIMIT_RTTIME is declared... no
checking whether SCHED_RESET_ON_FORK is declared... yes
checking for sphinx-build... No
checking for rpm... Yes
checking for rpmbuild... Yes

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating keepalived/Makefile
config.status: creating lib/Makefile
config.status: creating keepalived/core/Makefile
config.status: creating keepalived.spec
config.status: creating genhash/Makefile
config.status: creating keepalived/check/Makefile
config.status: creating keepalived/vrrp/Makefile
config.status: creating keepalived/bfd/Makefile
config.status: creating doc/Makefile
config.status: creating bin_install/Makefile
config.status: creating keepalived/dbus/Makefile
config.status: creating keepalived/etc/Makefile
config.status: creating keepalived/etc/init/Makefile
config.status: creating keepalived/etc/init.d/Makefile
config.status: creating lib/config.h
config.status: executing depfiles commands

Keepalived configuration
------------------------
Keepalived version       : 2.0.6
Compiler                 : gcc
Preprocessor flags       : 
Compiler flags           : -Wall -Wunused -Wstrict-prototypes -Wextra -Winit-self -g -D_GNU_SOURCE -Wimplicit-fallthrough=3 -fPIE -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -O2
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.

[root@abc keepalived-2.0.6]#

搞定。。。记录

 =====================================================

然后在另一台服务器安装,提示

[root@abc keepalived-2.0.6]# 
[root@abc keepalived-2.0.6]# yum -y install ipvsadm
已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
设置安装进程
Loading mirror speeds from cached hostfile
No package ipvsadm available.
错误:无须任何处理
[root@abc keepalived-2.0.6]# 

直接scp过来安装,rpm -ivh ipvsadm-1.26-2.el6.x86_64

然后编译keepalive还是报错:

checking for inotify_init1... yes
checking for vsyslog... yes
checking whether ETHERTYPE_IPV6 is declared... yes
checking openssl/ssl.h usability... no
checking openssl/ssl.h presence... no
checking for openssl/ssl.h... no
configure: error: 
  !!! OpenSSL is not properly installed on your system. !!!
  !!! Can not include OpenSSL headers files.            !!!
[root@abc keepalived-2.0.6]# yum  install openssl  -y
已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
设置安装进程
Loading mirror speeds from cached hostfile
匹配 openssl-1.0.1e-15.el6.x86_64 的软件包已经安装。检查更新。
无须任何处理
[root@abc keepalived-2.0.6]# 

检查编译日志:

[root@abc keepalived-2.0.6]# 
[root@abc keepalived-2.0.6]# grep error config.log 
cc1: error: unrecognized command line option "-Wimplicit-fallthrough=3"
configure:5547: checking for -Wformat -Werror=format-security support
configure:5554: gcc -c -g -O2 -D_GNU_SOURCE -Wformat -Werror=format-security  conftest.c >&5
cc1: error: unrecognized command line option "-fstack-protector-strong"
cc1: error: unrecognised debug output level "record-gcc-switches"
conftest.c:12:28: error: ac_nonexistent.h: No such file or directory
conftest.c:12:28: error: ac_nonexistent.h: No such file or directory
/usr/include/linux/netlink.h:35: error: expected specifier-qualifier-list before 'sa_family_t'
/usr/include/linux/netlink.h:35: error: expected specifier-qualifier-list before 'sa_family_t'
conftest.c:87: error: expected expression before ')' token
conftest.c:91: error: size of array 'test_array' is negative
conftest.c:89: error: expected expression before ')' token
conftest.c:89: error: expected expression before ')' token
conftest.c:86:19: error: vfork.h: No such file or directory
conftest.c:53:19: error: vfork.h: No such file or directory
configure:6768: checking for strerror
conftest.c:117:25: error: openssl/ssl.h: No such file or directory
conftest.c:84:25: error: openssl/ssl.h: No such file or directory
configure:6901: error: 
ac_cv_func_strerror=yes
KA_CFLAGS='-Wall -Wunused -Wstrict-prototypes -Wextra -Winit-self -g -D_GNU_SOURCE -fPIE -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -O2'
[root@abc keepalived-2.0.6]# 
[root@abc keepalived-2.0.6]#

 

 

 

 

先记录几个rpm地址:http://mirror.centos.org/centos/6/os/x86_64/Packages/

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄