标签:xtrabackup
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/tarball/percona-xtrabackup-2.4.7-Linux-x86_64.tar.gz
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL numactl -y
yum install numactl -y
mv bin/* /sbin/
3.热备份
xtrabackup项目
innobackupex是对xtrabackup封装的perl脚本,一般进行备份
备份:
innobackupex --defaults-file=/etc/my.cnf --user=root --password=123456 /bak/
恢复:
1./etc/init.d/mysql stop
2.删除老数据库中的数据文件和事务日志文件
恢复日志
3.innobackupex --defaults-file=/etc/my.cnf --apply-log /bak/2013-
恢复数据
4.innobackupex --defaults-file=/etc/my.cnf --copy-back /bak/2013-
5.chown -R mysql.mysql /data/
6./etc/init.d/mysql start
全量恢复:
1.全量备份
innobackupex --defaults-file=/etc/my.cnf /bak/fullbak/
2.增量备份
innobackupex --defaults-file=/etc/my.cnf --incremental /bak/incrementbak/ --incremental-basedir=/bak/fullbak/2013(日期)/
cd fullbak/2013(日期)/
增量恢复:
1./etc/init.d/mysql stop
1.先恢复增量事务日志
innobackupex --apply-log --read-only /bak/fullbak/
2.再恢复全量事务日志
innobackupex --apply-log /bak/fullbak/
3.将备份文件的数据恢复到数据库
innobackupex --copy-back /bak/fullbak/
4.chown -R mysql.mysql /data/
5. /etc/init.d/msyql start
SHOW MASTER STATUS;
show slave stats\G
mysql> GRANT REPLICATION SLAVE ON *.* TO ‘repl‘@‘%‘ IDENTIFIED BY ‘replpassword‘;
mysql> CHANGE MASTER TO MASTER_HOST = ‘dbmaster‘, MASTER_USER = ‘repl‘, MASTER_PASSWORD = ‘replpassword‘, MASTER_PORT = 3306, MASTER_LOG_FILE = ‘mysql-bin.000001‘, MASTER_LOG_POS = 643;
start slave;
标签:xtrabackup
原文地址:http://1043868.blog.51cto.com/1033868/1932846