Use Percona XtraBackup in multiple instances
Background
Percona XtraBackup is a backup tool developed by Percona. It mainly has two tools: XtraBackup and innobackupex. Innobackupex encapsulates XtraBackup and is a perl script. This document is relatively simple. innobackupex is used to back up data of 3306 instances and restore the data to 3307 instances. It also briefly introduces how to use this backup to restore data.
Install
Percona-xtrbackup can be installed using binary, source code, and yum. This article mainly uses yum for installation. The steps are as follows:
Yum install http://www.percona.com/downloads/percona-release/RedHat/0.1-3/percona-release-0.1-3.noarch.rpm
Yum install percona-xtrabackup.x86_64
Yum search percona
For other installation methods, visit the official website:
Http://www.percona.com/doc/percona-xtrabackup/2.2/installation.html
Http://www.percona.com/doc/percona-xtrabackup/2.2/installation/compiling_xtrabackup.html
Preparation
Create Backup Directory
Cd/
Mkdir data
Cd data
Mkdir backup
Create three directories in the backup Directory: mkdir {conf, incremental, full}
The specific functions of the three directories are as follows:
Conf: stores custom my. cnf configuration information.
Full: stores the first full backup data
Incremental: stores incremental Backup Data
Back up my. cnf to the conf directory
Cp/etc/my. cnf/data/backup/conf/3306.cnf
Cp/etc/my. cnf/data/backup/conf/3307.cnf
3306. Save cnf as it is. 3307. cnf needs to be modified. Add "datadir =/data/mysql/mysql_3307/data/" under the [mysqld] node /". To facilitate data recovery.
MySQL management-using XtraBackup for Hot Backup
MySQL open-source backup tool Xtrabackup backup deployment
MySQL Xtrabackup backup and recovery
Use XtraBackup to implement MySQL master-slave replication and quick deployment [master-slave table lock-free]
Install and use Xtrabackup from Percona to back up MySQL
Common parameters:
-- User: mysql user
-- Password: User password
-- Defaults-file: Specifies the path of the my. cnf file. If this parameter is not specified, the default my. cnf file of mysql is read.
-- Socket: the socket file corresponding to the mysql instance
Backup operations
1. Full backup
The first backup is a full backup, which is also the basis of Incremental backup.
Innobackupex -- user = root -- password = 123456 -- socket =/tmp/mysql_3306.sock -- defaults-file =/data/backup/conf/3306.cnf/data/backup/full/
Back up all data in the database to the/data/backup/full/directory for the first time. a subdirectory with the current timestamp is generated under the/data/backup/full/directory, 1. If you do not want to generate a timestamp subdirectory, you can use the -- no-timestamp parameter so that it does not automatically generate a timestamp subdirectory, therefore, the backup data will be stored under/data/backup/full. For full backup, you only need to specify the user name, password, and backup path for backup. The innobackupex: completed OK is displayed! The backup is successful.
Figure 1
Directory file after full backup, 2.
Figure 2
Mysql data DIRECTORY file, 3.
Figure 3
You can compare the directory files in figure 2 and Figure 3. The files generated by xtrabackup include backup-my.cnf, xtrabackup_checkpoints, xtrabackup_info, and xtrabackup_lofile.
File description:
Backup-my.cnf: mainly records Mysql parameters used in innobackupex.
# This MySQL options file was generated by innobackupex.
# The MySQL server
[Mysqld]
Innodb_checksum_algorithm = innodb
Innodb_data_file_path = ibdata1: 12 M: autoextend
Innodb_log_files_in_group = 2
Innodb_log_file_size = 50331648
Innodb_page_size = 16384
Innodb_undo_directory =.
Innodb_undo_tablespaces = 0
Xtrabackup_checkpoints: records the Backup Type and the start and end lsn locations. Backup_type has two types: full-prepared (full backup) and incremental (incremental Backup ).
Backup_type = full-prepared
From_lsn = 0
To_lsns = 8234580547
Last_lsns = 8234580547
Compact = 0
Xtrabackup_info: records mysql-related information.
Uuid = 3d090541-6649-11e4-bb2a-000c295bd3a3
Name =
Tool_name = innobackupex
Tool_command = -- user = root -- password =... -- incremental/data/backup/incremental/-- incremental-base =/data/backup/incremental/2014-11-07_14-24-54/-- defaults-file =/data/backup/conf/3306.cnf -- socket =/ tmp/mysql_3306.sock
Tool_version = 1.5.1-xtrabackup
Ibbackup_version = xtrabackup version 2.2.6 based on MySQL server 5.6.21 Linux (x86_64) (revision id :)
Server_version = 5.6.21-log
Start_time = 14:41:52
End_time = 14:42:27
Lock_time = 2
Binlog_pos =
Innodb_from_lsn = 8234579864
Innodb_to_lsn = 8234580547
Partial = N
Incremental = Y
Format = file
Compact = N
Compressed = N
Xtrabackup_logfile: xtrabackup your own log file, which is not directly visible in the new version.
For more details, please continue to read the highlights on the next page: