码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-07-11 17:35:31      阅读:204      评论:0      收藏:0      [点我收藏+]

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


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

原文地址:https://www.cnblogs.com/lhdz_bj/p/11170906.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!