主机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. 建库测试。