xtrabackup backup build mysql slave

After previous mysql to build new libraries are prepared to stop or stop synchronization database on now small business library equipment, and then copy the database to the new standby database, configure the new library equipment, then turn sync or database. However, this is no idle standby database to prepare to take the new library.
  Need to build a business from a busy database in a new standby database, the system delay is relatively high, so the database synchronization and can not stop. So we used percona of xtrabackup backup tool.
  Because as a backup to the backup database, so with -slave-info parameter after completion of the backup file is generated corresponding to a log binlog master repository for configuration synchronization. In order to ensure the consistency of the data used -slave-info parameter will be added within a certain period of time a global read-only lock, resulting in the library can not write, but the library than to stop synchronizing effects to be small. A total database 1.4T, 1.3T front of the backup is going well, there is no lock and delay. 100G data file at the time of the last backup creates a global read-only lock, causing a delay of about three hours, after backup is complete after about half an hour delay to catch up.
  Here are the main steps to build a backup repository in xtrabackup:
  1. Installation see "percona-xtrabackup backup and restore mysq Manual" document;
  2. open a open a full backup as a full backup slave, adding -slave-info parameter indicates that is used to make a backup of the slave, after completion will generate a xtrabackup_slave_info backup file, the backup is complete recording emperor library files and binary log position, to enable a synchronization.

[root@db-2-43 data]# innobackupex --user=root --password= root - --slave-info --no-timestamp /data/backup/pis_slave

  You will see the following message after successful backup:

innobackupex: Backup created in directory ‘/data/backup/pis_slave’
innobackupex: MySQL slave binlog position: master host ‘10.0.2.44’, filename ‘mysql-bin.012434′, position 525181886
131028 20:20:37  innobackupex: Connection to database server closed
131028 20:20:37  innobackupex: completed OK!

  After the backup is complete, it can not be used to restore some of the things you need to recover uncommitted, the need to restore redo logo of data, ensure data consistency

innobackupex --apply-log /data/backup/pis_slave/


The successful implementation will see the following information

xtrabackup: starting shutdown with innodb_fast_shutdown = 1
InnoDB: FTS optimize thread exiting.
InnoDB: Starting shutdown…
InnoDB: Shutdown completed; log sequence number 6370833331492
131029 14:12:41  innobackupex: completed OK!


The completion of the backup to the backup copy of the new standby database server
  4. Install the new database in the new standby database mysql. Note that before restoring to close the database, the database files empty directory, because if the data directory file exists, then there will not be covered. Then copy data recovery using the following command, the following commands of the backup copy of the data according to the data directory mysql my.cnf configuration information will be backed up. Or manually copy the files to the backup catalog data may be mysql.

innobackupex –copy-back /data/backup/pis_slave

  5. Start the database

mysqld_safe --user=mysql --ledir=/data/mysql/bin/ &

6. Configuration Synchronization
  view binlog position of the main library

[root@db-3-5 pis_slave]# cat xtrabackup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.012434', MASTER_LOG_POS=525181886

  Turn sync on

14:30:53 (none)>CHANGE MASTER TO
-> MASTER_HOST='10.0.2.44',
-> MASTER_USER='repl',
-> MASTER_PASSWORD='repl',
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE='mysql-bin.012434',
-> MASTER_LOG_POS=525181886,
-> MASTER_CONNECT_RETRY=10;
14:33:00 (none)> start slave;

Guess you like

Origin www.cnblogs.com/szz1113/p/11771618.html