当前位置:Gxlcms > 数据库问题 > linux上mysql MM(双主)架构及keepalived搭建

linux上mysql MM(双主)架构及keepalived搭建

时间:2021-07-01 10:21:17 帮助过:3人阅读


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搭建

标签:star   file   incr   auto   配置   stat   date   nlog   搭建   

人气教程排行