Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql- physical backup-Percona xtrabackup

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Xtrabackup is a backup tool developed by percona for mysql physical hot backup.

There are a total of 4 executable files after the software installation:

The innobackupex:perl script, which is used to back up non-innodb tables, also calls xtrabackup to back up the innodb table and interacts with mysql server. Such as: add read lock (FTWRL), get site (show slave status) and so on. That is, xtrabackup is encapsulated.

Xbcrypt: used to decrypt

Xbstream: similar to tar, a stream file format that supports concurrent writes. And xbcrypt are both in backup and decompression.

Xtrabackup:c/c++ compiled binary, used to back up innodb tables, has no interaction with mysql server

Principle

Communication mode: the interaction and coordination between xtrabackup and innobackupex is realized by controlling the creation and deletion of files.

Main documents:

Xtrabackup_suspended_1

Xtrabackup_suspended_2

Xtrabackup_log_copied

Example: take a look at how xtrabackup_suspended_2 coordinates the two tool processes during backup:

After starting the xtrabackup process, 1.innobackupex waits for xtrabackup to back up the innodb file by waiting for xtrabackup_suspended_2 to be created

After 2.xtrabackup backs up the innodb data, create the xtrabackup_suspended_2 in the specified directory, and then wait until the file is deleted by innobackupex

After 3.innobackupex detects that the file xtrabackup_suspended_2 has been created, it continues to go down

4.innobackupex deletes the file xtrabackup_suspended_2 after backing up the non-InnoDB table, which informs xtrabackup that it is ready to continue, and then waits for xtrabackup_log_copied to be created

After 5.xtrabackup detects the deletion of the xtrabackup_suspended_2 file, you can move on.

Backup process diagram

Description:

After 1.innobackupex starts, it will first fork a process, start the xtrabackup process, and then wait for xtrabackup to back up the ibd data files.

When 2.xtrabackup backs up InnoDB-related data, there are two threads, one is the redo copy thread, which is responsible for copying redo files, and the other is the ibd copy thread, which is responsible for copying ibd files. There is only one redo copy thread, which starts before the ibd copy thread and ends after the ibd thread ends. After the xtrabackup process starts execution, start the redo copy thread to copy the redo logs sequentially from the latest checkpoint point, and then start the ibd data copy thread, where the innobackupex process has been waiting (waiting for the file to be created) during the xtrabackup copy ibd process.

After the 3.xtrabackup copy completes the idb, notify the innobackupex (by creating the file) while entering and waiting (the redo thread still continues to copy).

When 4.innobackupex receives the xtrabackup notification, it executes FLUSH TABLES WITH READ LOCK (FTWRL), obtains the consistency point, and then starts backing up non-InnoDB files (including frm, MYD, MYI, CSV, opt, par, and so on). In the process of copying non-InnoDB files, because the database is global read-only, you should be especially careful if you back up the main database of the business. If there are more non-InnoDB tables (mainly MyISAM), the read-only time of the entire database will be longer, and this impact must be evaluated.

5. When innobackupex has copied all the non-InnoDB table files, notify xtrabackup (by deleting the file) and enter and wait (wait for another file to be created)

When 6.xtrabackup receives a non-InnoDB notification from innobackupex backup, it stops the redo copy thread and then notifies innobackupex redo log that the copy is complete (by creating a file)

After receiving the notification of the completion of the redo backup, 7.innobackupex begins to unlock and execute UNLOCK TABLES

8. Finally, the innobackupex and xtrabackup processes respectively complete the finishing work, such as releasing resources, writing backup metadata information, and so on. Innobackupex waits for the xtrabackup child process to finish and then exits.

In the backup process, the data files are read directly through the operating system, and only interact with the database when the SQL command is executed, which basically does not affect the operation of the database. When backing up non-innodb, there will be a period of read-only, which has no effect on backing up the innodb table.

Backing up innodb files and non-innodb files are done by copying files, but the implementation is different. Innodb uses page granularity (xtrabackup). When reading each page, the checksum value is checked to ensure that the data block is consistent; non-innodb is cp or tar (innobackupex). Because the file is FTWRL, the file on disk is complete, and the backup data is complete.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report