MariaDB 双主模式
主机IP1:192.168.1.140
主机IP2:192.168.1.141
配置之前:先创建目录。[两台主机都需要做]
mkdir -pv /Mariadb/data && chown -R mysql.mysql /Mariadb/data
mkdir -pv /binlog/ && chown -R mysql.mysql /binlog
mkdir -pv /relaylog/ && chown -R mysql.mysql /relaylog
140上的my.cnf文件配置
thread_concurrency = 4
datadir=/Mariadb/data
innodb_file_per_table = ON
log-bin=/binlog/master-bin
relay-log=/relaylog/relay-mysql
auto-increment-offset=1
auto-increment-increment=2
server-id=140
141上的my.cnf文件配置
thread_concurrency = 4
datadir=/Mariadb/data
innodb_file_per_table = ON
log-bin=/binlog/master-bin
relay-log=/relaylog/relay-mysql
auto-increment-offset=1
auto-increment-increment=2
server-id=141
140授权给141,141上配置:
grant replication slave,replication client on *.* to
‘xxx‘
@
‘192.168.1.141‘
identified by
‘xxx‘
;
show master status;标记为1(100)
141授权给140,140上配置:
grant replication slave,replication client on *.* to
‘xxx‘
@
‘192.168.1.141‘
identified by
‘xxx‘
;
show master status;标记为2(200)
建立连接:
140上配置:
stop slave;
change master to master_host=
‘192.168.1.114‘
,master_user=
‘xxx‘
,master_password=
‘xxx‘
,master_log_file=
‘master1-bin.000003‘
,master_log_pos=
100
;
start slave;
show slave status\G;
141上配置:
stop slave;
change master to master_host=
‘192.168.1.114‘
,master_user=
‘xxx‘
,master_password=
‘xxx‘
,master_log_file=
‘master1-bin.000003‘
,master_log_pos=
200
;
show slave status\G;
6. 建库测试。
本文出自 “常用文档” 博客,请务必保留此出处http://yujianglei.blog.51cto.com/7215578/1575546
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。