MySQL-VIP:10.0.5.76
MySQL-master1:10.0.5.41
MySQL-master2:10.0.5.75
OS版本:ubuntu 14.04 LTS
MySQL版本:5.5.43
Keepalived版本:v1.2.7 (08/14,2013) 二、Mysql Master to Master 配置 1、配置MySQL-master1:10.0.5.41 a) 修改mysql配置文件
vim /etc/mysql/my.cnf
user = mysql
log-bin=mysql-bin
server-id=1
binlog-ignore-db=mysql
replicate-ignore-db=mysql,information_schema
sync_binlog=1
auto_increment_offset=1
auto_increment_increment=2
slave-skip-errors=all b) 新建授权用户
/etc/init.d/mysql restart
mysql>CREATE USER 'replication'IDENTIFIED BY '123456';
mysql>grant replication slave on *.* to 'replication'@'10.0.5.75' identified by '123456' with grant option;
mysql> show master status \G
*************************** 1. row ***************************
File: mysql-bin.000032
Position: 107
Binlog_Do_DB:
Binlog_Ignore_DB: mysql
1 row in set (0.00 sec) c) 将10.0.5.75设置为10.0.5.41的主服务器
vim /etc/mysql/my.cnf
user = mysql
log-bin=mysql-bin
server-id=2
binlog-ignore-db=mysql
replicate-ignore-db=mysql,information_schema
sync_binlog=1
auto_increment_offset=2
auto_increment_increment=2
slave-skip-errors=all b) 新建授权用户
/etc/init.d/mysql restart
mysql>CREATE USER 'replication'IDENTIFIED BY '123456';
mysql>grant replication slave on *.* to 'replication'@'10.0.5.41' identified by '123456' with grant option;
mysql> show master status\G
*************************** 1. row ***************************
File: mysql-bin.000019
Position: 107
Binlog_Do_DB:
Binlog_Ignore_DB: mysql
1 row in set (0.00 sec) c) 将10.0.5.41设置为10.0.5.75的主服务器
MySQL> grant all privileges on *.* to 'root'@'%' identified by 'root';
MySQL> flush privileges; 远程登录测试
mysql -uroot -proot -h 10.0.5.76
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10818
Server version: 5.5.43-0ubuntu0.14.04.1-log (Ubuntu)
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> keepalived故障转移测试
从10.0.5.74一直去ping VIP,然后关闭10.0.5.41上的keepalived,正常情况下VIP就会切换到10.0.5.75上面去
开启10.0.5.75上的keepalived,关闭10.0.5.41上的keepalived,看是否能自动切换,正常情况下VIP又会属于10.0.5.41 MySQL故障转移测试
在10.0.5.41上关闭MySQL服务,看VIP是否会切换到10.0.5.75上
开启10.0.5.41上的MySQL和keepalived,然后关闭10.0.5.75上的MySQL,看VIP是否会切换到10.0.5.41上