当前位置:   article > 正文

mysql第三方工具Percona XtraBackup

mysql第三方工具Percona XtraBackup

安装xtrabackup

  1. yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
  2. yum -y install percona-xtrabackup-80

创建备份用户并设置权限

  1. CREATE USER 'mysqlbackup'@'localhost' IDENTIFIED BY 's3cr%T';
  2. GRANT BACKUP_ADMIN, PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'mysqlbackup'@'localhost';
  3. GRANT SELECT ON performance_schema.log_status TO 'mysqlbackup'@'localhost';
  4. GRANT SELECT ON performance_schema.keyring_component_status TO mysqlbackup@'localhost';
  5. FLUSH PRIVILEGES;

完全备份

  1. mkdir -p /data/backup/wanquan
  2. xtrabackup --user=mysqlbackup --password=s3cr%T --backup --target-dir=/data/backup/wanquan --datadir=/usr/local/mysql/data/
  3. 参数说明:
  4. --user: 指定备份用户
  5. --password:指定备份用户密码
  6. --backup:表示执行备份操作
  7. --target-dir:指定备份数据的存储目录
  8. --datadir:指定MySQL的数据目录

增量备份

  1. 查看完全备份lsn
  2. [root@localhost ~]# cat /data/backup/wanquan/xtrabackup_checkpoints
  3. backup_type = full-backuped
  4. from_lsn = 0
  5. to_lsn = 19643963
  6. last_lsn = 19643963
  7. flushed_lsn = 19643963
  8. redo_memory = 0
  9. redo_frames = 0

基于全量备份的增量备份

  1. xtrabackup --user=mysqlbackup --password=s3cr%T --backup --target-dir=/data/backup/zengliang --incremental-basedir=/data/backup/wanquan --datadir=/usr/local/mysql/data/
  2. --incremental-basedir:指定增量备份的基准目录

查看增量备份lsn

  1. [root@localhost ~]# cat /data/backup/zengliang/xtrabackup_checkpoints
  2. backup_type = incremental
  3. from_lsn = 19643963
  4. to_lsn = 19643973
  5. last_lsn = 19643973
  6. flushed_lsn = 19643973
  7. redo_memory = 0
  8. redo_frames = 0

将增量备份应用于完整备份

  1. xtrabackup --prepare --apply-log-only --target-dir=/data/backup/wanquan
  2. xtrabackup --prepare --target-dir=/data/backup/wanquan --incremental-dir=/data/backup/zengliang

恢复

xtrabackup --user=mysqlbackup --password=s3cr%T --copy-back --target-dir=/data/backup/wanquan

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/1004764
推荐阅读
相关标签
  

闽ICP备14008679号