In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how MySQL5.7 uses mysqldump to build gtid master and slave". In daily operation, I believe many people have doubts about how MySQL5.7 uses mysqldump to build gtid master and slave. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how MySQL5.7 uses mysqldump to build gtid master and slave". Next, please follow the editor to study!
Recently, an old system needs to be upgraded to a new one, mainly for hardware updates.
An one-master and two-slave environment is built on the new hardware side, and the data is mainly imported by developers into the new system, because the concurrency in the process of importing data is too large and writing is too intensive, so it is necessary to stop the slave first, and after the data is imported and checked, re-build the master-slave environment.
The mysql of the master-slave environment is 5.7.12, using gtid.
Here are the specific steps, and all those without special instructions are performed from the library:
1.stop slave; # # stop slave library
2.reset slave all; # # reset Master / Slave configuration Information
3. Using mysqldump to export the database on the main library, I wrote a script to perform the export. The script name is mysqlbackup.sh.
[root@iz2ze6jo3o3bqbcongnypqz export_mysql] # more mysqlbackup.sh
#! / bin/bash
Databases= ('xxx_0042')
Basepath='/alidata1/backup/export_mysql/'
User='root'
Passwd='xxxxxx'
If [!-d "$basepath"]; then
Mkdir-p "$basepath"
Fi
For db in ${databases [*]}
Do
/ bin/nice-n 19 / usr/bin/mysqldump-u$user-p$passwd-- log-error=$basepath$db-$ (date +% Y%m%d). Log--set-gtid-purged=on-- single-transaction-- databases $db > $basepath$db-$ (date +% Y%m%d). Sql
/ bin/nice-n 19 tar zPcf $basepath$db-$ (date +% Y%m%d). Sql.tar.gz $basepath$db-$ (date +% Y%m%d) .sql
Find $basepath-mtime + 7-name "* .sql.tar.gz"-exec rm-rf {}\
Done
Rm-rf $basepath
4. The exported file already contains information about GTID_PURGED, which is very useful, meaning that those things do not need to be executed since the library is opened.
[root@iz2ze6jo3o3bqbcongnypoz export_mysql] # grep GTID_PURGED xxx_0042-20171202.sql
SET @ @ GLOBAL.GTID_PURGED='c9c73c70-c089-11e7-8544-00163e0ad76e:1-49794683'
5. Transfer the backup file to the slave server, mine is more complicated, first transfer the file to the springboard, and then to the slave, the-I parameter is used to use Aliyun's key file, and ssh is also used.
Scp-I xx_aliyun.pem root@192.168.2.71:/alidata1/backup/export_mysql/xxx_0042-20171202.sql.tar.gz / home/guoliang/
Scp-I xx_aliyun.pem / home/guoliang/xxx_0042-20171202.sql.tar.gz root@192.168.2.72:/alidata1/backup/export_mysql
Scp-I xx_aliyun.pem / home/guoliang/xxx_0042-20171202.sql.tar.gz root@192.168.2.73:/alidata1/backup/export_mysql
6.reset master; # # reset the binlog on the slave server
7. Import data
Source / alidata1/backup/export_mysql/alidata1/backup/export_mysql/xxx_0042-20171202.sql
8. Execute change master
Change master to
Master_host='192.168.2.71'
Master_port=3306
Master_user='repl'
Master_password='REPLsafxxxxx'
MASTER_AUTO_POSITION = 1
9.show slave status\ G; # # checks the status of the slave, mainly focusing on whether the following two values are consistent with the values from the above grep.
Retrieved_Gtid_Set: c9c73c70-c089-11e7-8544-00163e0ad76e:49794684-50352676
Executed_Gtid_Set: c9c73c70-c089-11e7-8544-00163e0ad76e:1-49798235
10. When Seconds_Behind_Master: 0, the data synchronization is complete.
At this point, the study of "how MySQL5.7 uses mysqldump to build gtid master and slave" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.