一、软件:
MySql8.0.20
percona-xtrabackup-80-8.0.13-1.el7.x86_64
安装:
自已脑补
二、使用:
1.权限
CREATE USER 'xtrabk'@'127.0.0.1' IDENTIFIED BY 'Xtrabk#123';
GRANT BACKUP_ADMIN, PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'xtrabk'@'127.0.0.1';
GRANT SELECT ON performance_schema.log_status TO 'xtrabk'@'127.0.0.1';
FLUSH PRIVILEGES;
mysql_config_editor set --login-path=xtrlogin -uxtrabk -h127.0.0.1 -P3306 -pXtrabk#123
2.全备+增备
全备:
xtrabackup --login-path=xtrlogin --parallel=2 --stream=xbstream --extra-lsndir=/mysqlbackup/node2/checkpoint --tmpdir=/mysqlbackup/node2/tmp --backup --target-dir=/mysqlbackup/node2
增备:
xtrabackup --login-path=xtrlogin --parallel=2 --stream=xbstream --extra-lsndir=/mysqlbackup/node2/checkpoint --backup --incremental-basedir=/mysqlbackup/node2/checkpoint --backup --target-dir=/mysqlbackup/node2
3.恢复
全备恢复:
xtrabackup --prepare --parallel=2 --use-memory=1g --apply-log-only --target-dir=/mysqlbackup/node2
增备恢复:
xtrabackup --prepare --use-memory=1g --parallel=2 --apply-log-only --target-dir=/mysqlbackup/node2 --incremental-dir=/mysqlbackup/node2/checkpoint
应用事务日志+回滚未提交:
xtrabackup --prepare --use-memory=1g --parallel=2 --target-dir=/mysqlbackup/node2
最后一步copy把备份复制到datadir目录下:
xtrabackup --copy-back --target-dir=/mysqlbackup/node2