MySQL Master Master replication setup
Set the Bin-log, and configure the other person for their master
1. Build
1.1 Master1 is configured as a master for Master2
Master configuration (MY.CNF)
[mysqld]server_id=1
log-bin=/usr/local/mysql-5.6.16/log/mysql-bin
Skip-slave-start # Slave replication process does not start on startup
Auto_increment_offset=0
auto_increment_increment=2
replicate-do-db= Test
Replicate-ignore-db=mysql
Start Master1
./bin/mysqld_safe--defaults-file=/usr/local/mysql-5.6. 16/MY.CNF--user=mysql &
Create a user for replication
*. ' rep1 '@'192.168.80.102'rep1';
Back up data and restore to Master2 server
--Set read lock, data cannot be updated
Read lock;
--see where to start copying
Mysql>Show master status;+------------------+----------+--------------+------------------+-------------------+|File| Position| binlog_do_db | binlog_ignore_db | Executed_gtid_set | +------------------+----------+--------------+----- -------------+-------------------+| mysql-bin.000001 | 120 | | | | +------------------+- ---------+--------------+------------------+-------------------+
--Transfer data
192.168."tar-xzf--c/usr/local/mysql-5.6.16"
--Release lock
> Unlock tables;
Master2 Configuration (MY.CNF)
[mysqld]server_id=2 # Unique between master and slave
log-bin=/usr/local/mysql-5.6.16/log/mysql-bin
Skip-slave-start # Slave replication process does not start on startup
Auto_increment_offset=1
auto_increment_increment=2
Replicate-do-db=test
Replicate-ignore-db=mysql
Start Master2
./bin/mysqld_safe--defaults-file=/usr/local/mysql-5.6. 16/MY.CNF--user=mysql &
Configuring Replication Parameters
Mysql> Change MasterToMaster_host=‘192.168.80.101‘,Master_port=320W-> master_user=< Span style= "color: #ff0000;" > '
To start Master2 io and SQL threads
> Start slave;
Check
> Show Processlist \g
The following information should appear:
State:waiting for Master to send event
State:slave have read all relay log; Waiting for the slave I/O thread to update it
Or
> Show slave status \g
The following information should appear:
Slave_io_state:waiting for Master to send event
Slave_sql_running_state:slave have read all relay log; Waiting for the slave I/O thread to update it
1.2 Master2 the master configured as Master1
Perform a show master status operation on the Master2 and perform a change master to operation on the Master1 check.
MySQL Primary master replication