http://www.percona.com/
# yum install http://www.percona.com/redir/downloads/percona-release/redhat/latest/percona-release-0.1-3.noarch.rpm
查看所有percona軟件包
yum search percona
通過YUM安裝 percona-xtrabackup
# yum install percona-xtrabackup
通過RPM安裝 CentOS 6
http://www.percona.com/downloads/XtraBackup/LATEST/binary/redhat/6/x86_64/
# yum install -y http://www.percona.com/redir/downloads/XtraBackup/LATEST/binary/redhat/6/x86_64/percona-xtrabackup-2.2.6-5042.el6.x86_64.rpm
通過RPM安裝 CentOS 7
http://www.percona.com/downloads/XtraBackup/LATEST/binary/redhat/7/x86_64/
# yum install -y http://www.percona.com/redir/downloads/XtraBackup/LATEST/binary/redhat/7/x86_64/percona-xtrabackup-2.2.6-5042.el7.x86_64.rpm
卸載
# yum remove percona-xtrabackup
查看檔案列表
# rpm -ql percona-xtrabackup /usr/bin/innobackupex /usr/bin/xbcrypt /usr/bin/xbstream /usr/bin/xtrabackup /usr/share/doc/percona-xtrabackup-2.2.6 /usr/share/doc/percona-xtrabackup-2.2.6/COPYING
首先創建備份用戶
mysql> CREATE USER 'backup'@'localhost' IDENTIFIED BY 's3cret'; mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'backup'@'localhost'; mysql> FLUSH PRIVILEGES;
備份所有資料庫
# mkdir -p /backup # innobackupex --user=backup --password=chen /backup/full
備份指定資料庫
# innobackupex --user=backup --password=chen --database=test /backup
--defaults-file=/etc/my.cnf 參數
# innobackupex --defaults-file=/etc/my.cnf --user=backup --password=chen --database=test /backup
備份後打包
# innobackupex --user=backup --password=chen --database=test --stream=tar /backup/ > test.tar
打包並壓縮
# innobackupex --user=backup --password=chen --database=test --stream=tar /backup/ | gzip > test.tar.gz
備份到遠程伺服器
# innobackupex --user=backup --password=chen --defaults-file=/etc/my.cnf --database=test --stream=tar /backup | gzip | ssh neo@192.168.2.1 cat ">" /backup/backup-2014-11-12.tar.gz
增量備份
# innobackupex --user=backup --password=chen --database=test /backup/incremental # ls /backup/incremental 2014-11-12_13-45-26 # innobackupex --user=backup --password=chen --database=test --incremental --incremental-basedir=/backup/incremental/2014-11-12_13-45-26/ /backup/incremental
恢復數據首先停止MySQL服務
# service mysql stop
恢復檔案
# innobackupex --copy-back /path/to/BACKUP-DIR # innobackupex --user=backup --password=chen --apply-log /backup/full/2014-11-12_13-45-26/
數據恢復完成後修改權限
$ chown -R mysql:mysql /var/lib/mysql
增量備份恢復方法
innobackupex --apply-log --redo-only BASE-DIR innobackupex --apply-log --redo-only BASE-DIR --incremental-dir=INCREMENTAL-DIR-1 innobackupex --apply-log BASE-DIR --incremental-dir=INCREMENTAL-DIR-2 innobackupex --apply-log BASE-DIR innobackupex --copy-back BASE-DIR
$ innobackupex --stream=tar /tmp $ innobackupex --stream=xbstream /root/backup/ > /root/backup/backup.xbstream $ innobackupex --stream=xbstream --compress /root/backup/ > /root/backup/backup.xbstream $ xbstream -x < backup.xbstream -C /root/backup/ $ innobackupex --compress --stream=xbstream /root/backup/ | ssh user@otherhost "xbstream -x -C /root/backup/"
YUM安裝
# yum install -y percona-toolkit
RPM安裝
# yum install -y http://www.percona.com/redir/downloads/percona-toolkit/LATEST/RPM/percona-toolkit-2.2.11-1.noarch.rpm
percona-toolkit 所含的檔案
# rpm -ql percona-toolkit /usr/bin/pt-align /usr/bin/pt-archiver /usr/bin/pt-config-diff /usr/bin/pt-deadlock-logger /usr/bin/pt-diskstats /usr/bin/pt-duplicate-key-checker /usr/bin/pt-fifo-split /usr/bin/pt-find /usr/bin/pt-fingerprint /usr/bin/pt-fk-error-logger /usr/bin/pt-heartbeat /usr/bin/pt-index-usage /usr/bin/pt-ioprofile /usr/bin/pt-kill /usr/bin/pt-mext /usr/bin/pt-mysql-summary /usr/bin/pt-online-schema-change /usr/bin/pt-pmp /usr/bin/pt-query-digest /usr/bin/pt-show-grants /usr/bin/pt-sift /usr/bin/pt-slave-delay /usr/bin/pt-slave-find /usr/bin/pt-slave-restart /usr/bin/pt-stalk /usr/bin/pt-summary /usr/bin/pt-table-checksum /usr/bin/pt-table-sync /usr/bin/pt-table-usage /usr/bin/pt-upgrade /usr/bin/pt-variable-advisor /usr/bin/pt-visual-explain /usr/share/doc/percona-toolkit-2.2.11 /usr/share/doc/percona-toolkit-2.2.11/COPYING /usr/share/doc/percona-toolkit-2.2.11/Changelog /usr/share/doc/percona-toolkit-2.2.11/INSTALL /usr/share/doc/percona-toolkit-2.2.11/README /usr/share/man/man1/percona-toolkit.1p.gz /usr/share/man/man1/pt-align.1p.gz /usr/share/man/man1/pt-archiver.1p.gz /usr/share/man/man1/pt-config-diff.1p.gz /usr/share/man/man1/pt-deadlock-logger.1p.gz /usr/share/man/man1/pt-diskstats.1p.gz /usr/share/man/man1/pt-duplicate-key-checker.1p.gz /usr/share/man/man1/pt-fifo-split.1p.gz /usr/share/man/man1/pt-find.1p.gz /usr/share/man/man1/pt-fingerprint.1p.gz /usr/share/man/man1/pt-fk-error-logger.1p.gz /usr/share/man/man1/pt-heartbeat.1p.gz /usr/share/man/man1/pt-index-usage.1p.gz /usr/share/man/man1/pt-ioprofile.1p.gz /usr/share/man/man1/pt-kill.1p.gz /usr/share/man/man1/pt-mext.1p.gz /usr/share/man/man1/pt-mysql-summary.1p.gz /usr/share/man/man1/pt-online-schema-change.1p.gz /usr/share/man/man1/pt-pmp.1p.gz /usr/share/man/man1/pt-query-digest.1p.gz /usr/share/man/man1/pt-show-grants.1p.gz /usr/share/man/man1/pt-sift.1p.gz /usr/share/man/man1/pt-slave-delay.1p.gz /usr/share/man/man1/pt-slave-find.1p.gz /usr/share/man/man1/pt-slave-restart.1p.gz /usr/share/man/man1/pt-stalk.1p.gz /usr/share/man/man1/pt-summary.1p.gz /usr/share/man/man1/pt-table-checksum.1p.gz /usr/share/man/man1/pt-table-sync.1p.gz /usr/share/man/man1/pt-table-usage.1p.gz /usr/share/man/man1/pt-upgrade.1p.gz /usr/share/man/man1/pt-variable-advisor.1p.gz /usr/share/man/man1/pt-visual-explain.1p.gz