keepalived01-安装keepalived
作者:互联网
- https://www.keepalived.org
- https://github.com/acassen/keepalived
1、安装keepalived(yum)
- keepalived主网站不提供任何Linux发行版的软件包,它只提供源代码和代码库。
- 大多数Linux发行版都提供keepalived包作为主线包,包维护人员在维护和报告有关它的问题方面做得很好。
1.1、安装前的准备
1、时间同步
#安装ntpdate yum install ntpdate -y #同步时间 ntpdate ntp1.aliyun.com
2、关闭防火墙
#查看防护墙状态 systemctl status firewalld.service #关闭防火墙 systemctl stop firewalld.service systemctl disable firewalld.service
3、禁用selinux
#查看selinux的状态 getenforce #临时有效 setenforce 0 #永久有效。改系统文件/etc/sysconfig/selinux,然后重启机器 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
4、开启网路接口的多播功能
#开启用于集群服务的网络接口的多播功能(MULTICAST状态) ip link set multicast on dev ens33
1.2、安装keepalived
1、安装keepalived
- CentoS 6.4版本之后,keepalived服务由base仓库提供。
yum install keepalived
2、查看keepalived服务的主要文件
]# rpm -ql keepalived /etc/keepalived/keepalived.conf #主配置文件 /etc/sysconfig/keepalived #Unit File的环境文件 /usr/lib/systemd/system/keepalived.service #Unit File /usr/sbin/keepalived #主程序文件 ......
1
2、安装keepalived(源码编译)
2.1、安装前的准备
1、时间同步
#安装ntpdate yum install ntpdate -y #同步时间 ntpdate ntp1.aliyun.com
2、关闭防火墙
#查看防护墙状态 systemctl status firewalld.service #关闭防火墙 systemctl stop firewalld.service systemctl disable firewalld.service
3、禁用selinux
#查看selinux的状态 getenforce #临时有效 setenforce 0 #永久有效。改系统文件/etc/sysconfig/selinux,然后重启机器 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
4、开启网路接口的多播功能
#开启用于集群服务的网络接口的多播功能(MULTICAST状态) ip link set multicast on dev ens33
2.2、安装keepalived
1、安装依赖
yum install gcc openssl-devel libnl libnl3-devel -y
2、安装keepalived
]# wget https://www.keepalived.org/software/keepalived-2.1.5.tar.gz --no-check-certificate ]# tar zvfx keepalived-2.1.5.tar.gz ]# cd keepalived-2.1.5/ ]# mkdir -pv /apps/keepalived-2.1.5 ]# ./configure --prefix=/apps/keepalived-2.1.5 ]# make && make install
- 问题:在执行make的时候由很多警告信息(不知道是否有影响)
]# make Making all in lib make[1]: 进入目录“/root/keepalived-2.1.5/lib” make all-am make[2]: 进入目录“/root/keepalived-2.1.5/lib” CC memory.o CC utils.o utils.c:1091:1: 警告:function might be candidate for attribute ‘pure’ [-Wsuggest-attribute=pure] memcmp_constant_time(const void *s1, const void *s2, size_t n) ^ CC notify.o CC timer.o CC scheduler.o CC vector.o CC html.o CC parser.o CC signals.o CC logger.o CC list_head.o CC rbtree.o CC process.o CC json_writer.o CC rttables.o rttables.c:60:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_LOCAL, "local", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:61:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_NAT, "nat", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:62:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_BROADCAST, "broadcast", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:63:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_BROADCAST, "brd", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:64:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_ANYCAST, "anycast", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:65:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_MULTICAST, "multicast", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:66:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_PROHIBIT, "prohibit", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:67:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_UNREACHABLE, "unreachable", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:68:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_BLACKHOLE, "blackhole", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:69:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_XRESOLVE, "xresolve", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:70:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_UNICAST, "unicast", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:71:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTN_THROW, "throw", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:72:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { 0, NULL, {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:76:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_UNSPEC, "none", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:77:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_REDIRECT, "redirect", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:78:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_KERNEL, "kernel", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:79:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_BOOT, "boot", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:80:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_STATIC, "static", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:82:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_GATED, "gated", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:83:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_RA, "ra", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:84:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_MRT, "mrt", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:85:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_ZEBRA, "zebra", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:86:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_BIRD, "bird", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:90:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_DNROUTED, "dnrouted", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:91:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_XORP, "xorp", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:92:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_NTK, "ntk", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:93:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RTPROT_DHCP, "dhcp", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:94:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { 0, NULL, {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:98:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_TABLE_DEFAULT, "default", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:99:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_TABLE_MAIN, "main", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:100:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_TABLE_LOCAL, "local", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:101:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { 0, NULL, {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:106:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_SCOPE_UNIVERSE, "global", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:107:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_SCOPE_NOWHERE, "nowhere", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:108:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_SCOPE_HOST, "host", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:109:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_SCOPE_LINK, "link", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:110:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { RT_SCOPE_SITE, "site", {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ rttables.c:111:2: 警告:missing initializer for field ‘next’ of ‘list_head_t’ [-Wmissing-field-initializers] { 0, NULL, {}}, ^ In file included from rttables.c:31:0: list_head.h:49:20: 附注:‘next’在此声明 struct list_head *next, *prev; ^ AR liblib.a make[2]: 离开目录“/root/keepalived-2.1.5/lib” make[1]: 离开目录“/root/keepalived-2.1.5/lib” Making all in keepalived make[1]: 进入目录“/root/keepalived-2.1.5/keepalived” Making all in core make[2]: 进入目录“/root/keepalived-2.1.5/keepalived/core” CC main.o main.c: 在函数‘sigend’中: main.c:952:34: 警告:assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow] for (i = 0; i < NUM_CHILD_TERM && wait_count; i++) { ^ main.c:990:6: 警告:assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow] if (wait_count) { ^ main.c:917:8: 警告:assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow] while (wait_count) { ^ CC daemon.o CC pidfile.o CC layer4.o CC smtp.o CC global_data.o CC global_parser.o CC keepalived_netlink.o CC namespaces.o In file included from /usr/include/libnl3/netlink/socket.h:16:0, from namespaces.c:171: /usr/include/libnl3/netlink/handlers.h:51:15: 警告:‘struct nlmsgerr’在形参表内部声明 [默认启用] struct nlmsgerr *nlerr, void *arg); ^ /usr/include/libnl3/netlink/handlers.h:51:15: 警告:它的作用域仅限于此定义或声明,这可能并不是您想要的 [默认启用] /usr/include/libnl3/netlink/handlers.h:51:15: 警告:‘struct sockaddr_nl’在形参表内部声明 [默认启用] /usr/include/libnl3/netlink/handlers.h:137:18: 警告:‘struct sockaddr_nl’在形参表内部声明 [默认启用] struct ucred **)); ^ CC track_process.o CC reload_monitor.o AR libcore.a make[2]: 离开目录“/root/keepalived-2.1.5/keepalived/core” Making all in vrrp make[2]: 进入目录“/root/keepalived-2.1.5/keepalived/vrrp” CC vrrp_daemon.o CC vrrp_print.o CC vrrp_data.o CC vrrp_parser.o CC vrrp.o CC vrrp_notify.o CC vrrp_scheduler.o vrrp_scheduler.c: 在函数‘try_up_instance’中: vrrp_scheduler.c:612:2: 警告:missing initializer for field ‘ifa’ of ‘ip_address_t’ [-Wmissing-field-initializers] ip_address_t ip_addr = {}; ^ In file included from ../../keepalived/include/vrrp_arp.h:33:0, from vrrp_scheduler.c:43: ../../keepalived/include/vrrp_ipaddress.h:43:19: 附注:‘ifa’在此声明 struct ifaddrmsg ifa; ^ vrrp_scheduler.c: 在函数‘vrrp_dispatcher_read’中: vrrp_scheduler.c:945:6: 警告:提领类型双关的指针将破坏强重叠规则 [-Wstrict-aliasing] vrrp->rx_ttl_hop_limit = *(unsigned int *)CMSG_DATA(cmsg); ^ In file included from /usr/include/netinet/ip.h:24:0, from vrrp_scheduler.c:26: vrrp_scheduler.c:951:60: 警告:提领类型双关的指针将破坏强重叠规则 [-Wstrict-aliasing] vrrp->multicast_pkt = IN6_IS_ADDR_MULTICAST(&((struct in6_pktinfo *)CMSG_DATA(cmsg))->ipi6_addr); ^ CC vrrp_sync.o CC vrrp_arp.o CC vrrp_if.o vrrp_if.c: 在函数‘set_default_garp_delay’中: vrrp_if.c:434:2: 警告:missing initializer for field ‘garp_interval’ of ‘garp_delay_t’ [-Wmissing-field-initializers] garp_delay_t default_delay = {}; ^ In file included from ../../keepalived/include/global_data.h:52:0, from vrrp_if.c:54: ../../keepalived/include/vrrp_if.h:74:13: 附注:‘garp_interval’在此声明 timeval_t garp_interval; /* Delay between sending gratuitous ARP messages on an interface */ ^ CC vrrp_track.o CC vrrp_ipaddress.o vrrp_ipaddress.c: 在函数‘clear_diff_static_addresses’中: vrrp_ipaddress.c:768:2: 警告:missing initializer for field ‘family’ of ‘vrrp_t’ [-Wmissing-field-initializers] vrrp_t old = {}; ^ In file included from ../../keepalived/include/vrrp_ipaddress.h:35:0, from vrrp_ipaddress.c:31: ../../keepalived/include/vrrp.h:213:15: 附注:‘family’在此声明 sa_family_t family; /* AF_INET|AF_INET6 */ ^ vrrp_ipaddress.c:769:2: 警告:missing initializer for field ‘family’ of ‘vrrp_t’ [-Wmissing-field-initializers] vrrp_t new = {}; ^ In file included from ../../keepalived/include/vrrp_ipaddress.h:35:0, from vrrp_ipaddress.c:31: ../../keepalived/include/vrrp.h:213:15: 附注:‘family’在此声明 sa_family_t family; /* AF_INET|AF_INET6 */ ^ CC vrrp_ndisc.o CC vrrp_if_config.o CC vrrp_static_track.o CC vrrp_vmac.o CC vrrp_ipsecah.o CC vrrp_iproute.o CC vrrp_iprule.o CC vrrp_ip_rule_route_parser.o AR libvrrp.a make[2]: 离开目录“/root/keepalived-2.1.5/keepalived/vrrp” Making all in check make[2]: 进入目录“/root/keepalived-2.1.5/keepalived/check” CC check_daemon.o CC check_data.o CC check_parser.o CC check_api.o CC check_tcp.o CC check_http.o CC check_ssl.o CC check_smtp.o CC check_misc.o CC check_dns.o CC check_print.o CC ipwrapper.o CC ipvswrapper.o CC libipvs.o CC check_udp.o CC check_ping.o CC check_file.o AR libcheck.a make[2]: 离开目录“/root/keepalived-2.1.5/keepalived/check” Making all in trackers make[2]: 进入目录“/root/keepalived-2.1.5/keepalived/trackers” CC track_file.o AR libtracker.a make[2]: 离开目录“/root/keepalived-2.1.5/keepalived/trackers” Making all in etc make[2]: 进入目录“/root/keepalived-2.1.5/keepalived/etc” Making all in init make[3]: 进入目录“/root/keepalived-2.1.5/keepalived/etc/init” make[3]: 对“all”无需做任何事。 make[3]: 离开目录“/root/keepalived-2.1.5/keepalived/etc/init” Making all in init.d make[3]: 进入目录“/root/keepalived-2.1.5/keepalived/etc/init.d” make[3]: 对“all”无需做任何事。 make[3]: 离开目录“/root/keepalived-2.1.5/keepalived/etc/init.d” make[3]: 进入目录“/root/keepalived-2.1.5/keepalived/etc” make[3]: 对“all-am”无需做任何事。 make[3]: 离开目录“/root/keepalived-2.1.5/keepalived/etc” make[2]: 离开目录“/root/keepalived-2.1.5/keepalived/etc” make[2]: 进入目录“/root/keepalived-2.1.5/keepalived” CC main.o CCLD keepalived EDIT keepalived.service make[2]: 离开目录“/root/keepalived-2.1.5/keepalived” make[1]: 离开目录“/root/keepalived-2.1.5/keepalived” Making all in doc make[1]: 进入目录“/root/keepalived-2.1.5/doc” Making all in man/man8 make[2]: 进入目录“/root/keepalived-2.1.5/doc/man/man8” EDIT keepalived.8 make[2]: 离开目录“/root/keepalived-2.1.5/doc/man/man8” make[2]: 进入目录“/root/keepalived-2.1.5/doc” make[2]: 对“all-am”无需做任何事。 make[2]: 离开目录“/root/keepalived-2.1.5/doc” make[1]: 离开目录“/root/keepalived-2.1.5/doc” Making all in genhash make[1]: 进入目录“/root/keepalived-2.1.5/genhash” CC main.o main.c: 在函数‘usage’中: main.c:99:3: 警告:字符串长‘1003’比‘509’(ISO C90 被要求支持的最大长度) 还要长 [-Woverlength-strings] " --timeout -t Timeout in seconds\n"); ^ CC sock.o CC layer4.o CC http.o CC ssl.o CCLD genhash make[1]: 离开目录“/root/keepalived-2.1.5/genhash” Making all in bin_install make[1]: 进入目录“/root/keepalived-2.1.5/bin_install” make[1]: 离开目录“/root/keepalived-2.1.5/bin_install” make[1]: 进入目录“/root/keepalived-2.1.5” EDIT README make[1]: 离开目录“/root/keepalived-2.1.5”View Code
1
# #
标签:head,rttables,keepalived,list,next,field,keepalived01,安装 来源: https://www.cnblogs.com/maiblogs/p/16523246.html