设为首页 收藏本站
查看: 531|回复: 0

[经验分享] keepalived+mysql+centos6.4 简单配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-12-22 08:40:29 | 显示全部楼层 |阅读模式
  Keepalived安装
  [iyunv@leonfs keepalived-1.2.15]# ./configure --prefix=/usr/local/keepalived --disable-fwmark
  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 for a BSD-compatible install... /usr/bin/install -c
  checking for strip... strip
  checking how to run the C preprocessor... gcc -E
  checking for grep that handles long lines and -e... /bin/grep
  checking for egrep... /bin/grep -E
  checking for ANSI C header files... yes
  checking for sys/wait.h that is POSIX.1 compatible... 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 fcntl.h usability... yes
  checking fcntl.h presence... yes
  checking for fcntl.h... yes
  checking syslog.h usability... yes
  checking syslog.h presence... yes
  checking for syslog.h... yes
  checking for unistd.h... (cached) yes
  checking sys/ioctl.h usability... yes
  checking sys/ioctl.h presence... yes
  checking for sys/ioctl.h... yes
  checking sys/time.h usability... yes
  checking sys/time.h presence... yes
  checking for sys/time.h... yes
  checking openssl/ssl.h usability... yes
  checking openssl/ssl.h presence... yes
  checking for openssl/ssl.h... yes
  checking openssl/md5.h usability... yes
  checking openssl/md5.h presence... yes
  checking for openssl/md5.h... yes
  checking openssl/err.h usability... yes
  checking openssl/err.h presence... yes
  checking for openssl/err.h... yes
  checking whether ETHERTYPE_IPV6 is declared... no
  checking for crypt in -lcrypt... yes
  checking for MD5_Init in -lcrypto... yes
  checking for SSL_CTX_new in -lssl... yes
  checking for nl_socket_alloc in -lnl-3... no
  checking for nl_socket_modify_cb in -lnl... no
  configure: WARNING: keepalived will be built without libnl support.
  checking for kernel version... 2.6.18
  checking for IPVS syncd support... yes
  checking for kernel macvlan support... no
  checking for an ANSI C-conforming const... yes
  checking for pid_t... yes
  checking whether time.h and sys/time.h may both be included... yes
  checking whether gcc needs -traditional... no
  checking for working memcmp... yes
  checking return type of signal handlers... void
  checking for gettimeofday... yes
  checking for select... yes
  checking for socket... yes
  checking for strerror... yes
  checking for strtol... yes
  checking for uname... yes
  configure: creating ./config.status
  config.status: creating Makefile
  config.status: creating genhash/Makefile
  config.status: creating keepalived/core/Makefile
  config.status: creating lib/config.h
  config.status: creating keepalived.spec
  config.status: creating keepalived/Makefile
  config.status: creating lib/Makefile
  config.status: creating keepalived/vrrp/Makefile
  config.status: creating keepalived/check/Makefile
  config.status: creating keepalived/libipvs-2.6/Makefile
  
  Keepalived configuration
  ------------------------
  Keepalived version       : 1.2.15
  Compiler                 : gcc
  Compiler flags           : -g -O2 -DETHERTYPE_IPV6=0x86dd
  Extra Lib                : -lssl -lcrypto -lcrypt 
  Use IPVS Framework       : Yes
  IPVS sync daemon support : Yes
  IPVS use libnl           : No
  fwmark socket support    : No
  Use VRRP Framework       : Yes
  Use VRRP VMAC            : No
  SNMP support             : No
  SHA1 support             : No
  Use Debug flags          : No
  [iyunv@leonfs keepalived-1.2.15]# 
  [iyunv@leonfs keepalived-1.2.15]# make && make install
  make -C lib || exit 1;
  make[1]: Entering directory `/softw/keepalived-1.2.15/lib'
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c memory.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c utils.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c notify.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c timer.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c scheduler.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c vector.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c list.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c html.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c parser.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c signals.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c logger.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c list_head.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c buffer.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c command.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I. -Wall -Wunused -Wstrict-prototypes -D_WITHOUT_SNMP_ -c vty.c
  make[1]: Leaving directory `/softw/keepalived-1.2.15/lib'
  make -C keepalived
  make[1]: Entering directory `/softw/keepalived-1.2.15/keepalived'
  make[2]: Entering directory `/softw/keepalived-1.2.15/keepalived/core'
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c main.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c daemon.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c pidfile.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c layer4.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c smtp.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c global_data.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c global_parser.c
  make[2]: Leaving directory `/softw/keepalived-1.2.15/keepalived/core'
  make[2]: Entering directory `/softw/keepalived-1.2.15/keepalived/check'
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_daemon.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_data.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_parser.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_api.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_tcp.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_http.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_ssl.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_smtp.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c check_misc.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c ipwrapper.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -D_WITHOUT_SO_MARK_  -c ipvswrapper.c
  make[2]: Leaving directory `/softw/keepalived-1.2.15/keepalived/check'
  make[2]: Entering directory `/softw/keepalived-1.2.15/keepalived/vrrp'
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_daemon.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_data.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_parser.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_notify.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_scheduler.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_sync.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_index.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_netlink.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_arp.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_if.c
  vrrp_if.c: In function ‘if_mii_read’:
  vrrp_if.c:122: 警告:提领类型双关的指针将破坏强重叠规则
  vrrp_if.c: In function ‘if_mii_status’:
  vrrp_if.c:149: 警告:提领类型双关的指针将破坏强重叠规则
  vrrp_if.c: In function ‘if_mii_probe’:
  vrrp_if.c:191: 警告:提领类型双关的指针将破坏强重叠规则
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_track.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_ipaddress.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_iproute.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_ipsecah.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_ndisc.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_HAVE_IPVS_SYNCD_ -D_WITHOUT_VRRP_VMAC_ -D_WITHOUT_SNMP_  -c vrrp_vmac.c
  make[2]: Leaving directory `/softw/keepalived-1.2.15/keepalived/vrrp'
  make[2]: Entering directory `/softw/keepalived-1.2.15/keepalived/libipvs-2.6'
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -DLIBIPVS_DONTUSE_NL -Wall -Wunused -c -o libipvs.o libipvs.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -DLIBIPVS_DONTUSE_NL -Wall -Wunused -c -o ip_vs_nl_policy.o ip_vs_nl_policy.c
  ar rv libipvs.a libipvs.o ip_vs_nl_policy.o
  ar: creating libipvs.a
  a - libipvs.o
  a - ip_vs_nl_policy.o
  rm libipvs.o ip_vs_nl_policy.o
  make[2]: Leaving directory `/softw/keepalived-1.2.15/keepalived/libipvs-2.6'
  Building ../bin/keepalived
  strip ../bin/keepalived
  
  Make complete
  make[1]: Leaving directory `/softw/keepalived-1.2.15/keepalived'
  make -C genhash
  make[1]: Entering directory `/softw/keepalived-1.2.15/genhash'
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../lib -Wall -Wunused -Wstrict-prototypes   -c -o main.o main.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../lib -Wall -Wunused -Wstrict-prototypes   -c -o sock.o sock.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../lib -Wall -Wunused -Wstrict-prototypes   -c -o layer4.o layer4.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../lib -Wall -Wunused -Wstrict-prototypes   -c -o http.o http.c
  gcc -g -O2 -DETHERTYPE_IPV6=0x86dd  -I/usr/src/linux/include -I/usr/src/linux/include -I../lib -Wall -Wunused -Wstrict-prototypes   -c -o ssl.o ssl.c
  Building ../bin/genhash
  strip ../bin/genhash
  
  Make complete
  make[1]: Leaving directory `/softw/keepalived-1.2.15/genhash'
  Make complete
  make -C keepalived install
  make[1]: Entering directory `/softw/keepalived-1.2.15/keepalived'
  install -d /usr/local/keepalived/sbin
  install -m 700 ../bin/keepalived /usr/local/keepalived/sbin/
  install -d /usr/local/keepalived/etc/rc.d/init.d
  install -m 755 etc/init.d/keepalived.init /usr/local/keepalived/etc/rc.d/init.d/keepalived
  install -d /usr/local/keepalived/etc/sysconfig
  install -m 755 etc/init.d/keepalived.sysconfig /usr/local/keepalived/etc/sysconfig/keepalived
  install -d /usr/local/keepalived/etc/keepalived/samples
  install -m 644 etc/keepalived/keepalived.conf /usr/local/keepalived/etc/keepalived/
  install -m 644 ../doc/samples/* /usr/local/keepalived/etc/keepalived/samples/
  install -d /usr/local/keepalived/share/man/man5
  install -d /usr/local/keepalived/share/man/man8
  install -m 644 ../doc/man/man5/keepalived.conf.5 /usr/local/keepalived/share/man/man5
  install -m 644 ../doc/man/man8/keepalived.8 /usr/local/keepalived/share/man/man8
  make[1]: Leaving directory `/softw/keepalived-1.2.15/keepalived'
  make -C genhash install
  make[1]: Entering directory `/softw/keepalived-1.2.15/genhash'
  install -d /usr/local/keepalived/bin
  install -m 755 ../bin/genhash /usr/local/keepalived/bin/
  install -d /usr/local/keepalived/share/man/man1
  install -m 644 ../doc/man/man1/genhash.1 /usr/local/keepalived/share/man/man1
  make[1]: Leaving directory `/softw/keepalived-1.2.15/genhash'
主--192.168.0.53 3306
备--192.168.0.119 3306
Vip--192.168.0.222
以上均建立在主-从关系配置完毕的条件下
Keepalived编译安装后,默认情况下keepalived启动时会去/etc/keepalived目录下找配置文件
#mkdir /etc/keepalived
#vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived                                             
#global_defs {                                                                   
#     notification_email {       #指定keepalived在发生切换时需要发送email到的对象,一行一个                                                
#     luwenju@live.cn                                                            
#     }                                                                          
#     notification_email_from luwenju@live.cn #指定发件人                                    
#     smtp_server 127.0.0.1                      #smtp服务器地址                               
#     smtp_connect_timeout 30                   #指定smtp连接超时时间                                 
#     router_id MySQL-ha  #运行keepalived机器的标识,修改为自己的主机名                                                        
#     }                                                                          
#vrrp_sync_group VG_1{  #监控多个网段的实例/
#group{
#Inside_network  #实例名
#Outside_network
#}
#}                                                                                
vrrp_instance VI_1 {                                                     
     state BACKUP     #指定哪个为master,哪个为backup,如果设置了nopreempt,则此值不起作用,主备靠priority决定,两台配置此处均配置为BACKUP                                     
     interface eth0      #实例绑定的网卡,在配置VIP的时候必须是在已有网卡上添加的                                                         
     virtual_router_id 51  #默认为51    VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一个组                                                
     priority 100     #优先级(1-254),另一台改为90,优先级高的为master                                       
     advert_int 1    #组播信息检查间隔,默认1s ,两个节点的设置必须一样,以指明各个节点属于同一个VRRP组                                                            
     nopreempt    #不抢占,只在优先级高的机器上设置即可,优先级低的机器不设置,意思是即使主恢复正常之后也不把主抢回来,此值只能在backup主机上     
 #debug  #debug级别
 #dont_track_primary  #忽略vrrp的interface错误(默认不设置)
 #track_interface{  #设置额外的监控,里面哪个网卡出现问题都会切换
#eth0
#eth1
#}
     authentication {         #设置认证,两个节点必须一致                                                  
     auth_type PASS         #认证方式                                                   
     auth_pass 1111         #认证密码                                                    
     }                                                                          
     virtual_ipaddress {  #两个节点必须一致,大概可以有多个VIP                                                        
     192.168.0.222                                                              
     }                                                                          
     }                                                                          
                                                                                
virtual_server 192.168.0.222 3306 {                                             
     delay_loop 2   #健康检查时间间隔,每隔2秒检查一次real_server状态                             
     lb_algo wrr   #LVS算法 rr|wrr|lc|wlc|lblc|sh|dh                                                    
     lb_kind DR    #LVS模式 负载均衡转发规则 NAT|DR|RUN                                                    
     persistence_timeout 60   #会话保持时间                                     
     protocol TCP         #使用的协议                                                      
     real_server 192.168.0.53 3306 {                                           
     weight 3                                               
 #notify_up #检测到服务启动后执行的脚本                    
     notify_down /usr/local/mysql/bin/MySQL.sh  #检测到mysql服务down后执行的脚本     
     TCP_CHECK {                                                                
     connect_timeout 10    #连接超时时间                                        
     nb_get_retry 3         #重连次数                                             
     delay_before_retry 3   #重连间隔时间                                       
     connect_port 3306     #健康检查端口 --检测端口,当3306端口失败,会将其踢出集群                                         
     }                                                                          
     }                                                                          
编写检测服务down后所要执行的脚本
 #vi /usr/local/MySQL/bin/MySQL.sh  
  #!/bin/sh  
  pkill keepalived  
  #chmod +x /usr/local/MySQL/bin/MySQL.sh
注:此脚本是上面配置文件notify_down选项所用到的,keepalived使用notify_down选项来检查real_server的服务状态,当发现real_server服务故障时,便触发此脚本;我们可以看到,脚本就一个命令,通过pkill keepalived强制杀死keepalived进程,从而实现了MySQL故障自动转移。另外,我们不用担心两个MySQL会同时提供数据更新操作,因为每台MySQL上的keepalived的配置里面只有本机MySQL的IP+VIP,而不是两台MySQL的IP+VIP
启动keepalived
[iyunv@leonfs keepalived]# /usr/local/keepalived/sbin/keepalived -D
[iyunv@leonfs keepalived]# ps -ef|grep keep
root     30225     1  0 14:16 ?        00:00:00 /usr/local/keepalived/sbin/keepalived -D
root     30226 30225  0 14:16 ?        00:00:00 /usr/local/keepalived/sbin/keepalived -D
root     30227 30225  0 14:16 ?        00:00:00 /usr/local/keepalived/sbin/keepalived -D
在其他机器上ping vip:ping 192.168.0.222,可以ping通,关闭mysql服务,查看keepalived健康检查程序是否会触发编写的脚本(notify_down:MySQL.sh):经确认触发(执行pkill keepalived)。
--可使用ip addr命令查看vip
[iyunv@leonfs local]# ip addr
1: lo:  mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:2a:31:8a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.53/24 brd 192.168.0.255 scope global eth0
    inet 192.168.0.222/32 scope global eth0
3: eth1:  mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:2a:31:94 brd ff:ff:ff:ff:ff:ff

  
在从库(192.168.0.119 3307)安装keepalived,并配置(修改配置优先级为90、无抢占设置、real_server为本机IP)
! Configuration File for keepalived            
#global_defs {                                  
#     notification_email {                      
#     luwenju@live.cn                           
#     }                                         
#     notification_email_from luwenju@live.cn   
#     smtp_server 127.0.0.1                     
#     smtp_connect_timeout 30                   
#     router_id MySQL-ha  修改为自己的主机名                       
#     }                                         
                                               
vrrp_instance VI_1 {                           
     state BACKUP                              
     interface eth0                            
     virtual_router_id 51                      
     priority 90                               
     advert_int 1                              
     authentication {                          
     auth_type PASS                            
     auth_pass 1111                            
     }                                         
     virtual_ipaddress {                       
     192.168.0.222                             
     }                                         
     }                                         
                                               
virtual_server 192.168.1.222 3306 {            
     delay_loop 2                              
     lb_algo wrr                               
     lb_kind DR                                
     persistence_timeout 60                    
     protocol TCP                              
     real_server 192.168.0.119 3306 {          
     weight 3                                  
     notify_down /usr/local/mysql/bin/MySQL.sh 
     TCP_CHECK {                               
     connect_timeout 10                        
     nb_get_retry 3                            
     delay_before_retry 3                      
     connect_port 3307                         
     }                                         
     }                                         
编写notify_down脚本(同主库即可),启动,测试。
从客户端使用vip登录,确认成功登录
[mysql@dgryxrdb ~]$mysql -uroot -proot -P3306 -h192.168.0.222
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 985
Server version: 5.7.7-rc-log MySQL Community Server (GPL)

  
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

  
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

  
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| db1                |
| db2                |
| db3                |
| mycat_th           |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
8 rows in set (0.00 sec)

  
Keepalived故障转移测试:
※在windows客户端一直去ping  VIP(192.168.0.222),然后关闭192.168.0.53上的keepalived,正常情况下VIP就会切换到192.168.0.119上面去
※开启192.168.0.53上的keepalived,关闭192.168.0.119上的keepalived,看是否能自动切换,正常情况下VIP又会属于192.168.0.53
MySQL故障转移测试
※在192.168.0.53上关闭MySQL服务,看VIP是否会切换到192.168.0.119上
※开启192.168.0.119上的MySQL和keepalived,然后关闭192.168.0.119上的MySQL,看VIP是否会切换到192.168.0.53上

  
notify_master /etc/keepalived/scripts/start_haproxy.sh  #表示当切换到master状态时,要执行的脚本
notify_fault  /etc/keepalived/scripts/stop_keepalived.sh #故障时执行的脚本
notify_stop  /etc/keepalived/scripts/stop_haproxy.sh # keepalived停止运行前运行notify_stop指定的脚本 }

  
--添加服务
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived  /etc/rc.d/init.d/
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

  
VRRPD配置包括3个类:
VRRP同步组(synchroization group)
VRRP实例(VRRP Instance)
VRRP脚本(VRRP Script),
这里使用的是VRRP实例,VRRP脚本。
存在闹裂的可能性,即两个节点实际都处于正常工作状态,但是无法接收到彼此的组播通知,这时两个节点均强行绑定VIP,导致不可预料的后果。这时需要设置仲裁,即每个节点必须判断自身的状态(应用服务状态及自身网络状态),要实现这两点可使用自定义shell脚本实现,通过周期性的检查自身应用服务状态,并不断ping网关(或其他可靠的IP)均可。当自身服务异常或无法ping通网关,则认为自身出现故障,就应该移除掉VIP(停止keepalived即可),主要借助keepalived提供的vrrp_script及track_script实现。
可以在conf文件里编写脚本如
Vrrp_script chk_haproxy(script_name){#定义一个检查脚本
script “filename”#shell脚本的路径,文件自定义规则可为:自身web服务故障(超时,http返回状态不是200);无法ping通网关;产生以上问题即可停止keepalived
Interval 5#运行间隔
}
然后在vrrp_instance VI_1{
Track_script{
Chk_haproxy
}
}
注:vrrp_script与vrrp_instance是一个级别的
如果是主-主模式,conf可以配置2个vrrp_instance,每个vrrp_instance对应1个vip,如下所示
vrrp_instance vip1 {
    state MASTER
    interface eth0
    virtual_router_id 51   #本机两个vrrp_instance组的此值不能相同,但对应备用节点的此值必须相同
    priority 99       #对应备用节点值应该比此值小
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.100.1 /24
    }
}

  
vrrp_instance vip2 {
    state BACKUP
    interface eth0
    virtual_router_id 52  #本机两个vrrp_instance组的此值不能相同,但对应主节点的此值必须相同
    priority 90     #主节点的值应该比此值大
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.100.2 /24
    }
}
另1节点配置相反。需要做好本地服务检测,以防止闹裂。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-154539-1-1.html 上篇帖子: Mysql各版本介绍及下载 下篇帖子: MySQL-5.5.28编译安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表