Home  >  Article  >  Database  >  MySQL - code example to upgrade BinLog Replication to GTIDs Replication in four steps

MySQL - code example to upgrade BinLog Replication to GTIDs Replication in four steps

黄舟
黄舟Original
2017-03-13 16:43:101131browse

1. Set both the Master and Slave servers to read-only

mysql>SET @@global.read_only=ON;

2. Stop both the Master and Slave servers

service mysql stop

3. Enable GTIDs

To enable GTIDs, you need to configure gtid-mode, log-bin, log-slave-updates, and enforce-gtid-consistency on both the master and slave servers (before MySQL 5.6.9, it was --disable-gtid-unsafe-statement ). In addition, the slave needs to add the skip-slave-start parameter in this link.

#vi /etc/my.cnf
[mysqld]
gtid-mode=on
log-bin
log-slave-updates
enforce-gtid-consistency

4. Reconfigure Slave

mysql> change master to
	-> master_host='xxx.xxx.xxx.xxx',
	-> master_port=3306,
	-> master_user='xxx',
	-> master_password='xxx',
	-> master_auto_position=1;
mysql > start slave;

At this point, the upgrade is completed. Now I will add a GTIDs Replication method for switching relay server or Master server.

5. GTIDs Replication

GTIDs Replication can arbitrarily designate a server as the relay Slave server or Master server of another server.

For example, if there are three MySQL servers A, B, and C, A is the Master server of B and C. Currently, B is to be turned into a relay server for C. The specific operation method is as follows:

1) Execute the following commands on server B
mysql>  GRANT REPLICATION SLAVE ON *.* TO 'lyz'@'C的ip地址' IDENTIFIED BY 'lyz';
2) Execute the following operations on server C in sequence

(1) Stop the slave

mysql> stop slave;

(2)Configure slave

mysql> change master to
	-> master_host='B的ip地址',
	-> master_port=3306,
	-> master_user='lyz',
	-> master_password='lyz',
	-> master_auto_position=1;

(3)Start slave

mysql > start slave;

The above is the detailed content of MySQL - code example to upgrade BinLog Replication to GTIDs Replication in four steps. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn