MySQL主主复制故障自动切换解决方案
MySQL主主复制故障自动切换解决方案
1. MySQL-VIP:192.168.0.50
2. MySQL-master1:192.168.0.42
3. MySQL-master2:192.168.0.49
5. OS版本:CentOS 5.5
6. MySQL版本:5.5.13
7. Keepalived版本:keepalived-1.2.7.tar.gz
一、MySQL master-master配置
1、修改MySQL配置文件
两台MySQL均如要开启binlog日志功能,开启方法:在MySQL配置文件[MySQLd]段中加上log-bin=MySQL-bin选项
两台MySQL的server-ID不能一样,默认情况下两台MySQL的serverID都是1,需将其中一台修改为2即可
这里省略掉创建主主过程,简单描述如下,在2太服务器上分别创建账号,然后实例化彼此的从服务器!即可!
二、keepalived安装及配置
安装keepalived
1. #tar zxvf keepalived-1.1.20.tar.gz
2. #cd keepalived-1.1.20
3. #./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-i686
4. #make && make install
[root@slave01 keepalived-1.2.7]# ./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-i686
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 MD5_Init in -lcrypto... yes
checking for SSL_CTX_new in -lssl... yes
checking for poptGetContext in -lpopt... yes
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 keepalived/include/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.7
Compiler : gcc
Compiler flags : -g -O2 -DETHERTYPE_IPV6=0x86dd
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
IPVS use libnl : No
Use VRRP Framework : Yes
Use VRRP VMAC : No
SNMP support : No
Use Debug flags : No
[root@slave01 keepalived-1.2.7]# make && make install
make -C lib || exit 1;
make[1]: Entering directory `/usr/local/keepalived-1.2.7/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/local/keepalived-1.2.7/lib'
make -C keepalived
make[1]: Entering directory `/usr/local/keepalived-1.2.7/keepalived'
make[2]: Entering directory `/usr/local/keepalived-1.2.7/keepalived/core'
gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I/usr/src/kernels/2.6.18-164.el5-i686/include -I/usr/src/kernels/2.6.18-164.el5-i686/include -I../include -I../../lib -Wall -Wunused -Wstrict-prototypes -D_KRNL_2_6_ -D_WITH_LVS_ -D_WITH_VRRP_ -D_WITHOUT_SNMP_ -c main.c
make[2]: Leaving directory `/usr/local/keepalived-1.2.7/keepalived/core'
make[2]: Entering directory `/usr/local/keepalived-1.2.7/keepalived/check'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/keepalived-1.2.7/keepalived/check'
make[2]: Entering directory `/usr/local/keepalived-1.2.7/keepalived/vrrp'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/keepalived-1.2.7/keepalived/vrrp'
make[2]: Entering directory `/usr/local/keepalived-1.2.7/keepalived/libipvs-2.6'
gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I/usr/src/kernels/2.6.18-164.el5-i686/include -I/usr/src/kernels/2.6.18-164.el5-i686/include -DLIBIPVS_DONTUSE_NL -Wall -Wunused -c -o libipvs.o libipvs.c
gcc -g -O2 -DETHERTYPE_IPV6=0x86dd -I/usr/src/kernels/2.6.18-164.el5-i686/include -I/usr/src/kernels/2.6.18-164.el5-i686/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
r - libipvs.o
r - ip_vs_nl_policy.o
rm libipvs.o ip_vs_nl_policy.o
make[2]: Leaving directory `/usr/local/keepalived-1.2.7/keepalived/libipvs-2.6'
Building ../bin/keepalived
strip ../bin/keepalived
Make complete
make[1]: Leaving directory `/usr/local/keepalived-1.2.7/keepalived'
make -C genhash
make[1]: Entering directory `/usr/local/keepalived-1.2.7/genhash'
strip ../bin/genhash
Make complete
make[1]: Leaving directory `/usr/local/keepalived-1.2.7/genhash'
Make complete
make -C keepalived install
make[1]: Entering directory `/usr/local/keepalived-1.2.7/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 `/usr/local/keepalived-1.2.7/keepalived'
make -C genhash install
make[1]: Entering directory `/usr/local/keepalived-1.2.7/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 `/usr/local/keepalived-1.2.7/genhash
|
评论暂时关闭