使用Percona XtraBackup备份工具创建MySQL Slave
在原来搭建MySQL Slave如果可以停同步停库对应用响应要求不高,直接拷贝数据到新备库,配置好后在启用同步就可以了.但是在一些紧急情况下:比如业务超级繁忙的系统,数据库和同步又不能停去做一个MySQL Slave,这个时候XtraBackup就派上用场了.
下面重点介绍用XtraBackup做MySQL Slave的步骤
一、安装XtraBackup
[mysql@localhost backup]$ ll /etc/yum.repos.d/Percona.repo
-rw-r--r--. 1 root root 189 Dec 10 10:33 /etc/yum.repos.d/Percona.repo
[mysql@localhost ~]$ sudo yum install xtrabackup
二、用XtraBackup创建一个完全备份
[mysql@localhost ~]$ innobackupex-1.5.1 --user=root --password=root --port=3306 --defaults-file=/etc/my.cnf --slave-info --no-timestamp /mysql/backup
备份完成后会显示如下信息:
xtrabackup: Creating suspend file '/mysql/backup/xtrabackup_suspended_2' with pid '2963'
140209 11:31:21 innobackupex: Continuing after ibbackup has suspended
140209 11:31:21 innobackupex: Starting to lock all tables...
140209 11:31:21 innobackupex: All tables locked and flushed to disk
140209 11:31:21 innobackupex: Failed to get master binlog coordinates from SHOW SLAVE STATUS
140209 11:31:21 innobackupex: This means that the server is not a replication slave. Ignoring the --slave-info option
140209 11:31:21 innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/mysql/data'
innobackupex: Backing up file '/mysql/data/test/heartbeat.frm'
innobackupex: Backing up files '/mysql/data/performance_schema/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (53 files)
>> log scanned up to (4879018460)
innobackupex: Backing up file '/mysql/data/percona/test.frm'
innobackupex: Backing up file '/mysql/data/percona/db.opt'
innobackupex: Backing up files '/mysql/data/mysql/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (74 files)
140209 11:31:21 innobackupex: Finished backing up non-InnoDB tables and files
140209 11:31:21 innobackupex: Waiting for log copying to finish
xtrabackup: The latest check point (for incremental): '4879018460'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (4879018460)
xtrabackup: Creating suspend file '/mysql/backup/xtrabackup_log_copied' with pid '2963'
xtrabackup: Transaction log of lsn (4879018460) to (4879018460) was copied.
140209 11:31:22 innobackupex: All tables unlocked
在原来搭建MySQL Slave如果可以停同步停库对应用响应要求不高,直接拷贝数据到新备库,配置好后在启用同步就可以了.但是在一些紧急情况下:比如业务超级繁忙的系统,数据库和同步又不能停去做一个MySQL Slave,这个时候XtraBackup就派上用场了.
下面重点介绍用XtraBackup做MySQL Slave的步骤
一、安装XtraBackup
[mysql@localhost backup]$ ll /etc/yum.repos.d/Percona.repo
-rw-r--r--. 1 root root 189 Dec 10 10:33 /etc/yum.repos.d/Percona.repo
[mysql@localhost ~]$ sudo yum install xtrabackup
二、用XtraBackup创建一个完全备份
[mysql@localhost ~]$ innobackupex-1.5.1 --user=root --password=root --port=3306 --defaults-file=/etc/my.cnf --slave-info --no-timestamp /mysql/backup
备份完成后会显示如下信息:
xtrabackup: Creating suspend file '/mysql/backup/xtrabackup_suspended_2' with pid '2963'
140209 11:31:21 innobackupex: Continuing after ibbackup has suspended
140209 11:31:21 innobackupex: Starting to lock all tables...
140209 11:31:21 innobackupex: All tables locked and flushed to disk
140209 11:31:21 innobackupex: Failed to get master binlog coordinates from SHOW SLAVE STATUS
140209 11:31:21 innobackupex: This means that the server is not a replication slave. Ignoring the --slave-info option
140209 11:31:21 innobackupex: Starting to backup non-InnoDB tables and files
innobackupex: in subdirectories of '/mysql/data'
innobackupex: Backing up file '/mysql/data/test/heartbeat.frm'
innobackupex: Backing up files '/mysql/data/performance_schema/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (53 files)
>> log scanned up to (4879018460)
innobackupex: Backing up file '/mysql/data/percona/test.frm'
innobackupex: Backing up file '/mysql/data/percona/db.opt'
innobackupex: Backing up files '/mysql/data/mysql/*.{frm,isl,MYD,MYI,MAD,MAI,MRG,TRG,TRN,ARM,ARZ,CSM,CSV,opt,par}' (74 files)
140209 11:31:21 innobackupex: Finished backing up non-InnoDB tables and files
140209 11:31:21 innobackupex: Waiting for log copying to finish
xtrabackup: The latest check point (for incremental): '4879018460'
xtrabackup: Stopping log copying thread.
.>> log scanned up to (4879018460)
xtrabackup: Creating suspend file '/mysql/backup/xtrabackup_log_copied' with pid '2963'
xtrabackup: Transaction log of lsn (4879018460) to (4879018460) was copied.
140209 11:31:22 innobackupex: All tables unlocked