下載keepalived-2.0.6.tar.gz到/home/abc並解壓(解壓後的源碼目錄後面配置會用到):html
tar -zxvf keepalived-2.0.6.tar.gz
安裝前檢查了ipvsadm、popt-devel、openssl-devel、libnfnetlink-devel是否存在,結果以下:python
libnfnetlink-devel安裝的是libnfnetlink。linux
Package ipvsadm-1.26-2.el6.x86_64 already installed and latest version
執行編譯:ios
[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]#
報錯了,查看日誌:nginx
[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都是正常的:c++
[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 ~]#
查找找不到的庫,的確存在:express
[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/52873915centos
嘗試加入臨時環境變量:緩存
[root@abc keepalived-2.0.6]# export LD_LIBRARY_PATH=/usr/local/lib/:.:$LD_LIBRARY_PATH
問題解決:bash
[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/