keepalived+mysql+centos6.4 簡單配置

like052629發表於2015-05-14

Keepalived安裝

[root@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

[root@leonfs keepalived-1.2.15]# 

[root@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   #忽略vrrpinterface錯誤(預設不設定)

 #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的配置裡面只有本機MySQLIP+VIP,而不是兩臺MySQLIP+VIP

啟動keepalived

[root@leonfs keepalived]# /usr/local/keepalived/sbin/keepalived -D

[root@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 vipping 192.168.0.222,可以ping通,關閉mysql服務,檢視keepalived健康檢查程式是否會觸發編寫的指令碼(notify_downMySQL.sh):經確認觸發(執行pkill keepalived)。

--可使用ip addr命令檢視vip

[root@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上的MySQLkeepalived,然後關閉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_scripttrack_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_scriptvrrp_instance是一個級別的

如果是主-主模式,conf可以配置2vrrp_instance,每個vrrp_instance對應1vip,如下所示

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節點配置相反。需要做好本地服務檢測,以防止鬧裂。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28258625/viewspace-1654915/,如需轉載,請註明出處,否則將追究法律責任。

相關文章