keepalive编译安装keepalived-2.0.6
下载keepalived-2.0.6.tar.gz到/home/abc并解压(解压后的源码目录后面配置会用到):
tar -zxvf keepalived-2.0.6.tar.gz
安装前检查了ipvsadm、popt-devel、openssl-devel、libnfnetlink-devel是否存在,结果如下:
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]#
网上找资料发现是openssl的问题,那就安装:
[root@abc keepalived-2.0.6]# [root@abc keepalived-2.0.6]# yum install -y openssl openssl-devel 已加载插件:fastestmirror, product-id 设置安装进程 Loading mirror speeds from cached hostfile 解决依赖关系 --> 执行事务检查 pointing out that there is a problem. Eg.: 1. You have an upgrade for krb5-libs which is missing some dependency that another package requires. Yum is trying to solve this by installing an older version of krb5-libs of the different architecture. If you exclude the bad architecture yum will tell you what the root cause is (which package requires what). You can try redoing the upgrade with --exclude krb5-libs.otherarch ... this should give you an error message showing the root cause of the problem. 2. You have multiple architectures of krb5-libs installed, but yum can only see an upgrade for one of those arcitectures. If you don't want/need both architectures anymore then you can remove the one with the missing update and everything will work. 3. You have duplicate versions of krb5-libs installed already. You can use "yum check" to get yum show these errors. ...you can also use --setopt=protected_multilib=false to remove this checking, however this is almost never the correct thing to do as something else is very likely to go wrong (often causing much more problems). Protected multilib versions: krb5-libs-1.10.3-10.el6_4.6.i686 != krb5-libs-1.10.3-42.el6.x86_64 错误:Protected multilib versions: keyutils-libs-1.4-4.el6.i686 != keyutils-libs-1.4-5.el6.x86_64 错误:Protected multilib versions: openssl-1.0.1e-15.el6.i686 != openssl-1.0.1e-42.el6.x86_64 错误:Protected multilib versions: libcom_err-1.41.12-18.el6.i686 != libcom_err-1.41.12-22.el6.x86_64 错误:Protected multilib versions: libselinux-2.0.94-5.3.el6_4.1.i686 != libselinux-2.0.94-5.8.el6.x86_64 [root@abc keepalived-2.0.6]#
看到说是要安装的版本libselinux-2.0.94-5.3.el6_4.1.i686低于已安装的libselinux-2.0.94-5.8.el6.x86_64。
尝试使用yum downgrade libselinux,还是一堆错:
[root@abc keepalived-2.0.6]# [root@abc keepalived-2.0.6]# yum downgrade krb5-libs 已加载插件:fastestmirror, product-id Setting up Downgrade Process Loading mirror speeds from cached hostfile 解决依赖关系 --> 执行事务检查 ---> Package krb5-libs.x86_64 0:1.10.3-10.el6_4.6 will be a downgrade ---> Package krb5-libs.x86_64 0:1.10.3-42.el6 will be 删除 --> 完成依赖关系计算 错误:Package: krb5-workstation-1.10.3-42.el6.x86_64 (@anaconda-RedHatEnterpriseLinux-201507020259.x86_64/6.7) Requires: krb5-libs = 1.10.3-42.el6 正在删除: krb5-libs-1.10.3-42.el6.x86_64 (@anaconda-RedHatEnterpriseLinux-201507020259.x86_64/6.7) krb5-libs = 1.10.3-42.el6 Downgraded By: krb5-libs-1.10.3-10.el6_4.6.x86_64 (base) krb5-libs = 1.10.3-10.el6_4.6 You could try using --skip-broken to work around the problem ** Found 13 pre-existing rpmdb problem(s), 'yum check' output follows: glibc-2.12-1.132.el6.i686 has missing requires of glibc-common = ('0', '2.12', '1.132.el6') glibc-2.12-1.166.el6.i686 is a duplicate with glibc-2.12-1.132.el6.i686 glibc-devel-2.12-1.132.el6.i686 has missing requires of glibc-headers = ('0', '2.12', '1.132.el6') glibc-devel-2.12-1.166.el6.x86_64 is a duplicate with glibc-devel-2.12-1.132.el6.i686 libgcc-4.4.7-16.el6.i686 is a duplicate with libgcc-4.4.7-4.el6.i686 libstdc++-4.4.7-16.el6.i686 is a duplicate with libstdc++-4.4.7-4.el6.i686 nss-softokn-freebl-3.14.3-22.el6_6.i686 is a duplicate with nss-softokn-freebl-3.14.3-9.el6.i686 pcre-devel-7.8-6.el6.i686 has missing requires of libpcre.so.0 pcre-devel-7.8-6.el6.i686 has missing requires of libpcrecpp.so.0 pcre-devel-7.8-6.el6.i686 has missing requires of libpcreposix.so.0 python-urlgrabber-3.9.1-11.el6.noarch is a duplicate with python-urlgrabber-3.9.1-9.el6.noarch rhn-check-1.0.0.1-32.el6.noarch has missing requires of yum-rhn-plugin >= ('0', '0.9.1', '35') zlib-devel-1.2.3-29.el6.i686 has missing requires of libz.so.1 [root@abc keepalived-2.0.6]#
后来想到可能是系统为
[root@abc keepalived-2.0.6]# more /etc/redhat-release Red Hat Enterprise Linux Server release 6.7 (Santiago)
然后我这边挂载的yum为redhat6.5,可能跟这个有原因吧。所以更改yum为在线yum源,参考:https://jingyan.baidu.com/article/1709ad807601b34635c4f05b.html
直接到http://mirrors.163.com/.help/centos.html下载了对应版本的repo,备份了原始的repo,并根据系统实际情况修改了$releasesever 和$basearch,我这边修改为了6和x86_64
[root@abc keepalived-2.0.6]# [root@abc keepalived-2.0.6]# more /etc/yum.repos.d/CentOS6-Base-163.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-6 - Base - 163.com baseurl=http://mirrors.163.com/centos/6/os/x86_64/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-6 - Updates - 163.com baseurl=http://mirrors.163.com/centos/6/updates/x86_64/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-6 - Extras - 163.com baseurl=http://mirrors.163.com/centos/6/extras/x86_64/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-6 - Plus - 163.com baseurl=http://mirrors.163.com/centos/6/centosplus/x86_64/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-6 - Contrib - 163.com baseurl=http://mirrors.163.com/centos/6/contrib/x86_64/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 [root@abc keepalived-2.0.6]#
然后:
[root@abc keepalived-2.0.6]# yum clean all 已加载插件:fastestmirror, product-id Cleaning repos: base extras updates 清理一切 Cleaning up list of fastest mirrors [root@i-B56C455B keepalived-2.0.6]# yum makecache 已加载插件:fastestmirror, product-id Determining fastest mirrors base | 3.7 kB 00:00 base/group_gz | 242 kB 00:05 base/filelists_db | 6.4 MB 00:24 base/primary_db | 4.7 MB 00:14 base/other_db | 2.8 MB 00:09 extras | 3.4 kB 00:00 extras/filelists_db | 24 kB 00:04 extras/prestodelta | 2.2 kB 00:00 extras/primary_db | 29 kB 00:00 extras/other_db | 14 kB 00:00 updates | 3.4 kB 00:00 updates/filelists_db | 2.7 MB 00:19 updates/prestodelta | 138 kB 00:00 updates/primary_db | 3.7 MB 00:19 updates/other_db | 193 kB 00:01 元数据缓存已建立 [root@abc keepalived-2.0.6]#
搞定继续安装openssl-devel
[root@abc keepalived-2.0.6]# yum install -y openssl openssl-devel 已加载插件:fastestmirror, product-id 设置安装进程 Loading mirror speeds from cached hostfile 解决依赖关系 --> 执行事务检查 ---> Package openssl.x86_64 0:1.0.1e-42.el6 will be 升级 ---> Package openssl.x86_64 0:1.0.1e-57.el6 will be an update ---> Package openssl-devel.x86_64 0:1.0.1e-57.el6 will be 安装 --> 处理依赖关系 krb5-devel,它被软件包 openssl-devel-1.0.1e-57.el6.x86_64 需要 --> 执行事务检查 ---> Package krb5-devel.x86_64 0:1.10.3-65.el6 will be 安装 --> 处理依赖关系 libkadm5(x86-64) = 1.10.3-65.el6,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要 --> 处理依赖关系 krb5-libs = 1.10.3-65.el6,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要 --> 处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要 --> 处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要 --> 处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.10.3-65.el6.x86_64 需要 --> 执行事务检查 ---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be 安装 ---> Package krb5-libs.x86_64 0:1.10.3-42.el6 will be 升级 --> 处理依赖关系 krb5-libs = 1.10.3-42.el6,它被软件包 krb5-workstation-1.10.3-42.el6.x86_64 需要 ---> Package krb5-libs.x86_64 0:1.10.3-65.el6 will be an update ---> Package libcom_err-devel.x86_64 0:1.41.12-24.el6 will be 安装 --> 处理依赖关系 libcom_err = 1.41.12-24.el6,它被软件包 libcom_err-devel-1.41.12-24.el6.x86_64 需要 ---> Package libkadm5.x86_64 0:1.10.3-65.el6 will be 安装 ---> Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be 安装 --> 处理依赖关系 libselinux = 2.0.94-7.el6,它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要 --> 处理依赖关系 libsepol-devel >= 2.0.32-1,它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要 --> 处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要 --> 执行事务检查 ---> Package krb5-workstation.x86_64 0:1.10.3-42.el6 will be 升级 ---> Package krb5-workstation.x86_64 0:1.10.3-65.el6 will be an update ---> Package libcom_err.x86_64 0:1.41.12-22.el6 will be 升级 --> 处理依赖关系 libcom_err = 1.41.12-22.el6,它被软件包 libss-1.41.12-22.el6.x86_64 需要 --> 处理依赖关系 libcom_err = 1.41.12-22.el6,它被软件包 e2fsprogs-libs-1.41.12-22.el6.x86_64 需要 --> 处理依赖关系 libcom_err = 1.41.12-22.el6,它被软件包 e2fsprogs-1.41.12-22.el6.x86_64 需要 ---> Package libcom_err.x86_64 0:1.41.12-24.el6 will be an update ---> Package libselinux.x86_64 0:2.0.94-5.8.el6 will be 升级 --> 处理依赖关系 libselinux = 2.0.94-5.8.el6,它被软件包 libselinux-utils-2.0.94-5.8.el6.x86_64 需要 --> 处理依赖关系 libselinux = 2.0.94-5.8.el6,它被软件包 libselinux-python-2.0.94-5.8.el6.x86_64 需要 ---> Package libselinux.x86_64 0:2.0.94-7.el6 will be an update ---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be 安装 --> 执行事务检查 ---> Package e2fsprogs.x86_64 0:1.41.12-22.el6 will be 升级 ---> Package e2fsprogs.x86_64 0:1.41.12-24.el6 will be an update ---> Package e2fsprogs-libs.x86_64 0:1.41.12-22.el6 will be 升级 ---> Package e2fsprogs-libs.x86_64 0:1.41.12-24.el6 will be an update ---> Package libselinux-python.x86_64 0:2.0.94-5.8.el6 will be 升级 ---> Package libselinux-python.x86_64 0:2.0.94-7.el6 will be an update ---> Package libselinux-utils.x86_64 0:2.0.94-5.8.el6 will be 升级 ---> Package libselinux-utils.x86_64 0:2.0.94-7.el6 will be an update ---> Package libss.x86_64 0:1.41.12-22.el6 will be 升级 ---> Package libss.x86_64 0:1.41.12-24.el6 will be an update --> 完成依赖关系计算 依赖关系解决 ============================================================================================================ 软件包 架构 版本 仓库 大小 ============================================================================================================ 正在安装: openssl-devel x86_64 1.0.1e-57.el6 base 1.2 M 正在升级: openssl x86_64 1.0.1e-57.el6 base 1.5 M 为依赖而安装: keyutils-libs-devel x86_64 1.4-5.el6 base 29 k krb5-devel x86_64 1.10.3-65.el6 base 504 k libcom_err-devel x86_64 1.41.12-24.el6 base 33 k libkadm5 x86_64 1.10.3-65.el6 base 143 k libselinux-devel x86_64 2.0.94-7.el6 base 137 k libsepol-devel x86_64 2.0.41-4.el6 base 64 k 为依赖而更新: e2fsprogs x86_64 1.41.12-24.el6 base 554 k e2fsprogs-libs x86_64 1.41.12-24.el6 base 121 k krb5-libs x86_64 1.10.3-65.el6 base 675 k krb5-workstation x86_64 1.10.3-65.el6 base 814 k libcom_err x86_64 1.41.12-24.el6 base 38 k libselinux x86_64 2.0.94-7.el6 base 109 k libselinux-python x86_64 2.0.94-7.el6 base 203 k libselinux-utils x86_64 2.0.94-7.el6 base 82 k libss x86_64 1.41.12-24.el6 base 42 k 事务概要 ============================================================================================================ Install 7 Package(s) Upgrade 10 Package(s) 总下载量:6.2 M 下载软件包: (1/17): e2fsprogs-1.41.12-24.el6.x86_64.rpm | 554 kB 00:07 (2/17): e2fsprogs-libs-1.41.12-24.el6.x86_64.rpm | 121 kB 00:05 (3/17): keyutils-libs-devel-1.4-5.el6.x86_64.rpm | 29 kB 00:00 (4/17): krb5-devel-1.10.3-65.el6.x86_64.rpm | 504 kB 00:01 (5/17): krb5-libs-1.10.3-65.el6.x86_64.rpm | 675 kB 00:01 (6/17): krb5-workstation-1.10.3-65.el6.x86_64.rpm | 814 kB 00:02 (7/17): libcom_err-1.41.12-24.el6.x86_64.rpm | 38 kB 00:00 (8/17): libcom_err-devel-1.41.12-24.el6.x86_64.rpm | 33 kB 00:00 (9/17): libkadm5-1.10.3-65.el6.x86_64.rpm | 143 kB 00:00 (10/17): libselinux-2.0.94-7.el6.x86_64.rpm | 109 kB 00:00 (11/17): libselinux-devel-2.0.94-7.el6.x86_64.rpm | 137 kB 00:00 (12/17): libselinux-python-2.0.94-7.el6.x86_64.rpm | 203 kB 00:00 (13/17): libselinux-utils-2.0.94-7.el6.x86_64.rpm | 82 kB 00:00 (14/17): libsepol-devel-2.0.41-4.el6.x86_64.rpm | 64 kB 00:00 (15/17): libss-1.41.12-24.el6.x86_64.rpm | 42 kB 00:00 (16/17): openssl-1.0.1e-57.el6.x86_64.rpm | 1.5 MB 00:05 (17/17): openssl-devel-1.0.1e-57.el6.x86_64.rpm | 1.2 MB 00:03 ------------------------------------------------------------------------------------------------------------ 总计 147 kB/s | 6.2 MB 00:42 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Retrieving key from http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>" From : http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6 运行 rpm_check_debug 执行事务测试 事务测试成功 执行事务 Warning: RPMDB altered outside of yum. ** Found 13 pre-existing rpmdb problem(s), 'yum check' output follows: glibc-2.12-1.132.el6.i686 has missing requires of glibc-common = ('0', '2.12', '1.132.el6') glibc-2.12-1.166.el6.i686 is a duplicate with glibc-2.12-1.132.el6.i686 glibc-devel-2.12-1.132.el6.i686 has missing requires of glibc-headers = ('0', '2.12', '1.132.el6') glibc-devel-2.12-1.166.el6.x86_64 is a duplicate with glibc-devel-2.12-1.132.el6.i686 libgcc-4.4.7-16.el6.i686 is a duplicate with libgcc-4.4.7-4.el6.i686 libstdc++-4.4.7-16.el6.i686 is a duplicate with libstdc++-4.4.7-4.el6.i686 nss-softokn-freebl-3.14.3-22.el6_6.i686 is a duplicate with nss-softokn-freebl-3.14.3-9.el6.i686 pcre-devel-7.8-6.el6.i686 has missing requires of libpcre.so.0 pcre-devel-7.8-6.el6.i686 has missing requires of libpcrecpp.so.0 pcre-devel-7.8-6.el6.i686 has missing requires of libpcreposix.so.0 python-urlgrabber-3.9.1-11.el6.noarch is a duplicate with python-urlgrabber-3.9.1-9.el6.noarch rhn-check-1.0.0.1-32.el6.noarch has missing requires of yum-rhn-plugin >= ('0', '0.9.1', '35') zlib-devel-1.2.3-29.el6.i686 has missing requires of libz.so.1 正在升级 : libcom_err-1.41.12-24.el6.x86_64 1/27 正在升级 : libselinux-2.0.94-7.el6.x86_64 2/27 正在升级 : krb5-libs-1.10.3-65.el6.x86_64 3/27 正在安装 : libkadm5-1.10.3-65.el6.x86_64 4/27 正在升级 : libss-1.41.12-24.el6.x86_64 5/27 正在升级 : openssl-1.0.1e-57.el6.x86_64 6/27 正在安装 : libcom_err-devel-1.41.12-24.el6.x86_64 7/27 正在升级 : e2fsprogs-libs-1.41.12-24.el6.x86_64 8/27 正在安装 : libsepol-devel-2.0.41-4.el6.x86_64 9/27 正在安装 : libselinux-devel-2.0.94-7.el6.x86_64 10/27 正在安装 : keyutils-libs-devel-1.4-5.el6.x86_64 11/27 正在安装 : krb5-devel-1.10.3-65.el6.x86_64 12/27 正在安装 : openssl-devel-1.0.1e-57.el6.x86_64 13/27 正在升级 : e2fsprogs-1.41.12-24.el6.x86_64 14/27 正在升级 : krb5-workstation-1.10.3-65.el6.x86_64 15/27 正在升级 : libselinux-python-2.0.94-7.el6.x86_64 16/27 正在升级 : libselinux-utils-2.0.94-7.el6.x86_64 17/27 清理 : krb5-workstation-1.10.3-42.el6.x86_64 18/27 清理 : e2fsprogs-1.41.12-22.el6.x86_64 19/27 清理 : openssl-1.0.1e-42.el6.x86_64 20/27 清理 : krb5-libs-1.10.3-42.el6.x86_64 21/27 清理 : e2fsprogs-libs-1.41.12-22.el6.x86_64 22/27 清理 : libss-1.41.12-22.el6.x86_64 23/27 清理 : libselinux-utils-2.0.94-5.8.el6.x86_64 24/27 清理 : libselinux-python-2.0.94-5.8.el6.x86_64 25/27 清理 : libselinux-2.0.94-5.8.el6.x86_64 26/27 清理 : libcom_err-1.41.12-22.el6.x86_64 27/27 Verifying : krb5-devel-1.10.3-65.el6.x86_64 1/27 Verifying : krb5-libs-1.10.3-65.el6.x86_64 2/27 Verifying : krb5-workstation-1.10.3-65.el6.x86_64 3/27 Verifying : libcom_err-devel-1.41.12-24.el6.x86_64 4/27 Verifying : keyutils-libs-devel-1.4-5.el6.x86_64 5/27 Verifying : libss-1.41.12-24.el6.x86_64 6/27 Verifying : openssl-devel-1.0.1e-57.el6.x86_64 7/27 Verifying : e2fsprogs-libs-1.41.12-24.el6.x86_64 8/27 Verifying : libselinux-python-2.0.94-7.el6.x86_64 9/27 Verifying : libcom_err-1.41.12-24.el6.x86_64 10/27 Verifying : libsepol-devel-2.0.41-4.el6.x86_64 11/27 Verifying : libselinux-utils-2.0.94-7.el6.x86_64 12/27 Verifying : openssl-1.0.1e-57.el6.x86_64 13/27 Verifying : libkadm5-1.10.3-65.el6.x86_64 14/27 Verifying : libselinux-2.0.94-7.el6.x86_64 15/27 Verifying : libselinux-devel-2.0.94-7.el6.x86_64 16/27 Verifying : e2fsprogs-1.41.12-24.el6.x86_64 17/27 Verifying : libss-1.41.12-22.el6.x86_64 18/27 Verifying : libselinux-utils-2.0.94-5.8.el6.x86_64 19/27 Verifying : openssl-1.0.1e-42.el6.x86_64 20/27 Verifying : e2fsprogs-1.41.12-22.el6.x86_64 21/27 Verifying : krb5-libs-1.10.3-42.el6.x86_64 22/27 Verifying : krb5-workstation-1.10.3-42.el6.x86_64 23/27 Verifying : libselinux-2.0.94-5.8.el6.x86_64 24/27 Verifying : libcom_err-1.41.12-22.el6.x86_64 25/27 Verifying : libselinux-python-2.0.94-5.8.el6.x86_64 26/27 Verifying : e2fsprogs-libs-1.41.12-22.el6.x86_64 27/27 已安装: openssl-devel.x86_64 0:1.0.1e-57.el6 作为依赖被安装: keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-65.el6 libcom_err-devel.x86_64 0:1.41.12-24.el6 libkadm5.x86_64 0:1.10.3-65.el6 libselinux-devel.x86_64 0:2.0.94-7.el6 libsepol-devel.x86_64 0:2.0.41-4.el6 更新完毕: openssl.x86_64 0:1.0.1e-57.el6 作为依赖被升级: e2fsprogs.x86_64 0:1.41.12-24.el6 e2fsprogs-libs.x86_64 0:1.41.12-24.el6 krb5-libs.x86_64 0:1.10.3-65.el6 krb5-workstation.x86_64 0:1.10.3-65.el6 libcom_err.x86_64 0:1.41.12-24.el6 libselinux.x86_64 0:2.0.94-7.el6 libselinux-python.x86_64 0:2.0.94-7.el6 libselinux-utils.x86_64 0:2.0.94-7.el6 libss.x86_64 0:1.41.12-24.el6 完毕! [root@abc keepalived-2.0.6]#
成功安装,继续编译keepalive
[root@abc keepalived-2.0.6]# ./configure --prefix=/usr/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... no 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... no checking for --param=ssp-buffer-size=4 support... yes checking for -grecord-gcc-switches support... no 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... No 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: lib/config.h is unchanged 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 -fPIE -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -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]#
搞定,按部就班安装libnl-devel.x86_64 0:1.1.4-2.el6
编译还是报错:
继续安装libnfnetlink-devel
[root@abc keepalived-2.0.6]# [root@abc keepalived-2.0.6]# yum install libnfnetlink-devel 已加载插件:fastestmirror, product-id 设置安装进程 Loading mirror speeds from cached hostfile 解决依赖关系 --> 执行事务检查 ---> Package libnfnetlink-devel.x86_64 0:1.0.0-1.el6 will be 安装 --> 完成依赖关系计算 依赖关系解决 ============================================================================================================ 软件包 架构 版本 仓库 大小 ============================================================================================================ 正在安装: libnfnetlink-devel x86_64 1.0.0-1.el6 base 8.5 k 事务概要 ============================================================================================================ Install 1 Package(s) 总下载量:8.5 k Installed size: 8.1 k 确定吗?[y/N]:y 下载软件包: libnfnetlink-devel-1.0.0-1.el6.x86_64.rpm | 8.5 kB 00:00 运行 rpm_check_debug 执行事务测试 事务测试成功 执行事务 正在安装 : libnfnetlink-devel-1.0.0-1.el6.x86_64 1/1 Verifying : libnfnetlink-devel-1.0.0-1.el6.x86_64 1/1 已安装: libnfnetlink-devel.x86_64 0:1.0.0-1.el6 完毕! [root@abc keepalived-2.0.6]#
继续编译keepalive:
搞定环境问题........0.0..........,然后就是安装 make && make install
开始配置:
[root@abc keepalived-2.0.6]# #此时在家目录下的源码目录中 [root@abc keepalived-2.0.6]# pwd /home/abc/keepalived-2.0.6 [root@abc keepalived-2.0.6]# mkdir /etc/keepalived [root@abc keepalived-2.0.6]# cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/ #这里拷贝的是源码目录的文件(网上有说拷贝init.d/keepalived到/etc/ini.d中。1.2版本后这个文件在解压后的源码包中,如下方所示)
[root@abc keepalived-2.0.6]# cp keepalived/etc/init.d/keepalived /etc/init.d/
[root@abc keepalived-2.0.6]#
[root@abc keepalived-2.0.6]# cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
#启动文件,如果不加会报错:/bin/bash: keepalived: command not found
[root@i-B56C455B keepalived-2.0.6]# cp /usr/local/sbin/keepalived /usr/sbin/
#赋权
[root@abc keepalived-2.0.6]# chmod +x /etc/init.d/keepalived
#加入开机启动
[root@i-33D24D56 keepalived-2.0.6]# chkconfig --add keepalived
[root@i-33D24D56 keepalived-2.0.6]# chkconfig keepalived on
服务检查:
[root@abc keepalived-2.0.6]# service keepalived start Starting keepalived: [ OK ] [root@abc keepalived-2.0.6]# service keepalived stop Stopping keepalived: [ OK ] [root@abc keepalived-2.0.6]# service keepalived restart Stopping keepalived: [FAILED] Starting keepalived: [ OK ] [root@abc keepalived-2.0.6]#
配置keepalive,master节点:
[root@i-33D24D56 ~]# [root@i-33D24D56 ~]# more /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs {
#运行keepalive的机器标识,同一网段唯一 router_id i-33D24D56 } vrrp_script chknginx {
# 设置监测nginx是否启动的脚本 script "/usr/local/keepalived/checkNginx.sh" # 每秒检查一次
interval 1 weight -2 } vrrp_instance VI_1 {
# 设置为master节点 state MASTER
# 虚拟ip绑定的网卡名称 interface eth0
# 同一个keepalived组,节点的设置必须一样,这样才会被识别 virtual_router_id 111
# 节点的权重,备份节点值要比master节点低
priority 100 advert_int 1
# 上述eth0网卡真实的ip地址
mcast_src_ip=172.31.3.72 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress {
# 绑定虚拟ip到网卡 172.31.3.222/24 broadcast 172.31.3.255 dev eth0 scope global } track_script {
# 检测nginx的脚本,和vrrp_script chknginx保持一致 chknginx } } [root@i-33D24D56 ~]#
配置backup节点配置:
[root@i-B56C455B bin]# more /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs {
# 唯一标识 router_id i-B56C455B } vrrp_script chknginx { script "/usr/local/keepalived/checkNginx.sh" interval 1 weight -2 } vrrp_instance VI_1 {
# backup节点名称 state BACKUP interface eth0 virtual_router_id 111 priority 80 advert_int 1
# 网卡真实ip地址 mcast_src_ip=172.31.3.73 authentication { auth_type PASS auth_pass 1111 } virtual_ipaddress { 172.31.3.222/24 broadcast 172.31.3.255 dev eth0 scope global } track_script { chknginx } } [root@i-B56C455B bin]#
启动服务后,可以看到vip已经添加到对应的网卡上了:
[root@i-33D24D56 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d0:0d:33:d2:4d:56 brd ff:ff:ff:ff:ff:ff inet 172.31.3.72/24 brd 172.31.3.255 scope global eth0 inet 172.31.3.222/24 brd 172.31.3.255 scope global secondary eth0 inet6 fe80::d20d:33ff:fed2:4d56/64 scope link valid_lft forever preferred_lft forever [root@i-33D24D56 ~]#
关闭master节点前,查看backup节点:
[root@i-B56C455B bin]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d0:0d:b5:6c:45:5b brd ff:ff:ff:ff:ff:ff inet 172.31.3.73/24 brd 172.31.3.255 scope global eth0 inet6 fe80::d20d:b5ff:fe6c:455b/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 52:54:00:e5:d1:99 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 500 link/ether 52:54:00:e5:d1:99 brd ff:ff:ff:ff:ff:ff [root@i-B56C455B bin]#
关闭master节点后,vip漂移到了backup节点:
[root@i-33D24D56 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d0:0d:33:d2:4d:56 brd ff:ff:ff:ff:ff:ff inet 172.31.3.72/24 brd 172.31.3.255 scope global eth0 inet 172.31.3.222/24 brd 172.31.3.255 scope global secondary eth0 inet6 fe80::d20d:33ff:fed2:4d56/64 scope link valid_lft forever preferred_lft forever [root@i-33D24D56 ~]# service keepalived stop Stopping keepalived: [ OK ] [root@i-33D24D56 ~]# =====================上面是master节点关闭了============ [root@i-B56C455B bin]# [root@i-B56C455B bin]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d0:0d:b5:6c:45:5b brd ff:ff:ff:ff:ff:ff inet 172.31.3.73/24 brd 172.31.3.255 scope global eth0 inet6 fe80::d20d:b5ff:fe6c:455b/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 52:54:00:e5:d1:99 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 500 link/ether 52:54:00:e5:d1:99 brd ff:ff:ff:ff:ff:ff ==================上面是backup节点在master节点关闭前的ip=======下面是master关闭后的ip信息========= [root@i-B56C455B bin]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether d0:0d:b5:6c:45:5b brd ff:ff:ff:ff:ff:ff inet 172.31.3.73/24 brd 172.31.3.255 scope global eth0 inet 172.31.3.222/24 brd 172.31.3.255 scope global secondary eth0 inet6 fe80::d20d:b5ff:fe6c:455b/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether 52:54:00:e5:d1:99 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 500 link/ether 52:54:00:e5:d1:99 brd ff:ff:ff:ff:ff:ff [root@i-B56C455B bin]#
总结后续补充~
先记录几个rpm地址:http://mirror.centos.org/centos/6/os/x86_64/Packages/