Home > Database > Mysql Tutorial > 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

黄舟
Release: 2017-03-13 16:43:10
Original
1210 people have browsed it

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

mysql>SET @@global.read_only=ON;
Copy after login

2. Stop both the Master and Slave servers

service mysql stop
Copy after login

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
Copy after login

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;
Copy after login

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';
Copy after login
2) Execute the following operations on server C in sequence

(1) Stop the slave

mysql> stop slave;
Copy after login

(2)Configure slave

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

(3)Start slave

mysql > start slave;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template