mysql zrm_mysql数据库备份—ZRM
ZRM是Zmanda Recovery Manager的縮寫,這是一款備份mysql的開源軟件。
一、安裝
#yum install -y?MySQL-zrm
二、創(chuàng)建備用用戶
#mysql -uroot -p
mysql>grant select,insert,update,create,drop,reload,shutdown,alter,super,lock ? ?table,replication client on *.* to ‘backup‘@‘localhost‘ identified by ‘backup‘;
mysql>flush privileges
三、配置文件修改
#cd /etc/mysql-zrm
建議為每個需要備份的數(shù)據(jù)庫創(chuàng)建一個目錄加以區(qū)別,例如備份linux數(shù)據(jù)庫,則創(chuàng)建linux目錄
#mkdir linux
#cp -a mysql-zrm.conf linux
#cd linux
#vim?mysql-zrm.conf
backup-level=0 ? ? ? ? ? ? ? ? ?#0表示全備份,1為增量備份,也可以在命令中指定。
backup-mode=logical ? ? ?#備份方式,選擇為邏輯備份
destination=/data/backup #備份數(shù)據(jù)存放目錄,默認(rèn)在/var/log/mysql-zrm下
retention-policy=4W ? ? ? ?#備份文件保存時間,4W為一個月
compress=1 ? ? ? ? ? ? ? ? ? ? ?#備份文件選擇壓縮,使用gzip
databases=linux ? ? ? ? ? ? #選擇要備份的數(shù)據(jù)庫為linux
user="backup" ? ? ? ? ? ? ? #備份用戶
password="backup" ? ?#備份用戶密碼
socket=/var/lib/mysql/mysql.sock
verbose=1 ? ? ? ? ? ?#記錄詳細(xì)信息
四、備份數(shù)據(jù)
#mysql-zrm-scheduler --now --backup-set linux 在當(dāng)前狀態(tài)下對linux數(shù)據(jù)庫進(jìn)行完全備份
#mysql-zrm-scheduler --add --interval weekly --start 3:00 --day-of-week 1?--backup-level 0 --backup-set linux ?指定每周一3點(diǎn)對linux數(shù)據(jù)庫做一次完全備份
#mysql-zrm-scheduler --add --interval daily --start 1:00 --backup-level 1 --backup-set linux ?指定每天1點(diǎn)對數(shù)據(jù)庫做一次增量備份
#crontab -l
0 1 * * * /usr/bin/zrm-pre-scheduler --action backup --backup-set linux --backup-level 1 --interval daily
0 1 * * 1 /usr/bin/zrm-pre-scheduler --action backup --backup-set linux --backup-level 0 --interval weekly
五、備份數(shù)據(jù)查詢
#mysql-zrm-scheduler --query ? 查看備份日程
#mysql-zrm-reporter --where backup-set=linux --show backup-status-info ?查看備份狀態(tài)
#mysql-zrm-reporter --where backup-set=linux --show backup-performance-info 查看備份結(jié)果
#mysql-zrm --action verify-backup --backup-set linux --verbose 檢驗(yàn)備份結(jié)果
六、恢復(fù)
#mysql-zrm-reporter --show restore-info where backup-set=linux 查看備份數(shù)據(jù)
#mysql-zrm --action restore --source=directory /var/lib/mysql-zrm/linux/20140821160716/ ? ? --backup-set linux --verbose ?進(jìn)行恢復(fù)
本文出自 “不萊梅樂隊(duì)” 博客,謝絕轉(zhuǎn)載!
總結(jié)
以上是生活随笔為你收集整理的mysql zrm_mysql数据库备份—ZRM的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Python】提升Python程序性能
- 下一篇: 【数据库】Mysql函数DATE_ADD