1, more simple implementation of failover, do not need to find log_file and Log_pos before.
2, more simple to build master-slave replication.
3, more secure than the traditional copy.
4, Gtid is continuous without empty, to ensure the consistency of data, 0 lost.
Perform the following operations on the slave side (normal master-slave replication)--refer to http://blog.51cto.com/yangkui/2135027
([email protected]) [(None)]> change MASTER to
Master_host= ' 192.168.1.135 ',
Master_user= ' Repl ',
-master_password= ' xxx ',
master_port=3306,
-master_auto_position = 1;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
([email protected]) [(None)]> start slave;
Query OK, 0 rows affected (0.01 sec)
([email protected]) [(none)]> show slave status \g # # #可以看到复制工作已经开始且正常
1. Row
Slave_io_state:waiting for Master to send event
master_host:192.168.1.135
Master_user:repl
master_port:3306
Connect_retry:60
master_log_file:master-binlog.000001
read_master_log_pos:151
relay_log_file:slave-relay-log.000002
relay_log_pos:369
relay_master_log_file:master-binlog.000001
Slave_io_running:yes
Slave_sql_running:yes
修改配置文件1、主:
[Mysqld]
#GTID:
server_id=135 #服务器id
Gtid_mode=on #开启gtid模式
Enforce_gtid_consistency=on #强制gtid一致性, not supported for specific CREATE table after opening
#binlog
Log_bin=master-binlog
Log-slave-updates=1
Binlog_format=row #强烈建议, other formats may cause inconsistent data
#relay Log
Skip_slave_start=1
2, from:
[Mysqld]
#GTID:
Gtid_mode=on
Enforce_gtid_consistency=on
server_id=143
#binlog
Log-bin=slave-binlog
Log-slave-updates=1
Binlog_format=row #强烈建议, other formats may cause inconsistent data
#relay Log
SKIP_SLAVE_START=1B, all server settings global.read_only parameters, waiting for master-slave server synchronization completed;
Mysql> SET @ @global. read_only = on;
C, restart the master-slave server in turn;
D, using change Master to update the master-slave configuration;
Mysql> Change MASTER to
Master_host = HOST,
Master_port = PORT,
Master_user = USER,
Master_password = PASSWORD,
Master_auto_position = 1;
E, open copy from library
Mysql> START SLAVE;
F, verify master-slave replication
Configuring MySQL GTID master-slave replication