linux上mysql MM(双主)架构及keepalived搭建
Posted lhdz_bj
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux上mysql MM(双主)架构及keepalived搭建相关的知识,希望对你有一定的参考价值。
master1 10.1.1.14 VIP 10.1.1.16
master2 10.1.1.15 VIP 10.1.1.16
一.mysql MM配置
1.修改master1的my.cnf
# vi /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/mysqld.log
port = 3306
socket=/usr/local/mysql/mysql.sock
pid-file=/usr/local/mysql/mysql.pid
expire-logs-days=10
#binlog-do-db=db1
#binlog-ignore-db=db2
server-id = 1
log-bin = binlog
relay_log = relay-bin
log_slave_updates =1
auto_increment_increment=2
auto_increment_offset=1
2.修改master2的my.cnf
# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql/
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/mysqld.log
port = 3306
socket=/usr/local/mysql/mysql.sock
pid-file=/usr/local/mysql/mysql.pid
expire-logs-days=10
#binlog-do-db=db1
#binlog-ignore-db=db2
server-id=2
relay_log=relay-bin
log_bin =binlog
log_slave_updates =1
auto_increment_increment=2
auto_increment_offset=2
3.创建master1复制账号
grant replication slave,replication client on *.* to ‘repl‘@‘10.1.1.15‘ identified by ‘repl‘;
4.创建master2复制账号
grant replication slave,replication client on *.* to ‘repl‘@‘10.1.1.14‘ identified by ‘repl‘;
5.为master1配置master
show master status;
change master to master_host=‘10.1.1.15‘,master_user=‘repl‘,master_password=‘repl‘,master_log_file=‘binlog.000005‘,master_log_pos=154;
6.为master2配置master
show master status;
change master to master_host=‘10.1.1.14‘,master_user=‘repl‘,master_password=‘repl‘,master_log_file=‘binlog.000001‘,master_log_pos=154;
7.启动slave
master1:
start slave;
master2:
start slave;
以上是关于linux上mysql MM(双主)架构及keepalived搭建的主要内容,如果未能解决你的问题,请参考以下文章