In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to follow the GTID in the MYSQL architecture. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
GTID, also known as global transaction ID (Global Transaction ID), is the number of a committed transaction and is a globally unique number. After version 5.6 of Mysql, GTID replication has been added to the master-slave replication type.
GTID is made up of server_uuid and transaction ID. That is, GUID=server_id:transaction_id.server_uuid is automatically generated during database startup. The server_uuid of each machine is different, and it is also different after the same environment is deleted and rebuilt.
How it works:
1. When master updates data, GTID is generated before the transaction and recorded in the binlog log.
2. The I / O thread on the slave side writes the changed binlog to the local relay log.
3. The sql thread gets the GTID from the relay log, and then compares whether the binlog on the slave side has a record.
4. If there is a record, the transaction for the GTID has been executed and slave will ignore it.
5. If there is no record, slave will execute the transaction of the GTID from relay log and record it to binlog.
Environment configuration
/
Primary server
From the server
Ip
192.168.31.79
192.168.31.188
Hostname
Mysql
Mysql2
Mysql-version
5.7.23
5.7.23
Server-id
F99accbf-6690-11ea-a934-080027c1c1ff
A535303f-668e-11ea-8be9-080027b0e953
1. Main library configuration
1.1 Parameter configuration
[root@mysql2 bin] # vi / etc/my.cnf
Add the following content
Gtid_mode=on
Enforce_gtid_consistency=on
Log_bin=on
Binlog_format=row
Server-id=79
[root@mysql2 bin] # service mysql stop
[root@mysql2 bin] # service mysql stop
1.2 permission configuration
[root@mysql bin] # mysql-uroot-p
Mysql > grant replication slave on *. * to 'rep'@'192.168.31.%' identified by' Oracle123'
Mysql > flush privileges
two。 Backup data from master library to restore from slave library
Note: if it is a newly built environment, you do not have to do the migration steps.
3. Slave library configuration
2.1 configuration from library parameters
[root@mysql2 bin] # vi / etc/my.cnf
Add the following content
Gtid_mode=on
Enforce_gtid_consistency=on
Log_slave_updates=1
Serve-id=188
2.2 configuration of permissions from the library
[root@mysql2 bin] # mysql-uroot-p
Mysql > change master to master_host='192.168.31.79', master_user='rep',master_password='Oracle123',master_port=3306,master_auto_position=1
Mysql > start slave
3. Check master-slave status
1) main library
Mysql > show master status
2) from the library
Mysql > show slave status\ G
4. Verification
1) main library
Mysql > create database test
2) from the library
Mysql > show databases
Note:
After mysql version 5.7, gtid_executed values are persisted
Mysql > use mysql
Mysql > desc gtid_executed
Mysql > select * from gtid_executed
During the execution of reset master, the data in the table is emptied.
Mysql > show variables like'% gtid_executed%'
This parameter is used to control the compression of the gtid_ executed table. The default value is 1000. It means that the table compression is performed in 1000
It starts after the transaction.
The above is how to master and follow GTID in the MYSQL architecture shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.