====== 安裝與設定 AutoMySQLBackup ====== * 安裝環境 : CentOS 6.9 x86_64 * 安裝版本 : automysqlbackup-v3.0_rc6 ===== 下載與安裝 ===== * su - root mkdir -p source/automysqlbackup cd source/automysqlbackup wget https://nchc.dl.sourceforge.net/project/automysqlbackup/AutoMySQLBackup/AutoMySQLBackup%20VER%203.0/automysqlbackup-v3.0_rc6.tar.gz tar -zxvf automysqlbackup-v3.0_rc6.tar.gz ./install.sh * 如果都採用預設值, 設定檔將會安裝至 /etc/automysqlbackup/ , 執行檔將會安裝至 /usr/local/bin/ ===== 修改與設定 ===== * 更改 /etc/automysqlbackup/myserver.conf 成為符合自己環境的設定 Exp. : CONFIG_mysql_dump_username='root' CONFIG_mysql_dump_password='xxxx' CONFIG_mysql_dump_host='localhost' CONFIG_backup_dir='/backup/db' : * 第一次手動執行 automysqlbackup /etc/automysqlbackup/myserver.conf * 設定每天自動執行 vi /etc/cron.daily/runmysqlbackup #!/bin/sh /usr/local/bin/automysqlbackup /etc/automysqlbackup/myserver.conf chown root.root /var/backup/db* -R find /var/backup/db* -type f -exec chmod 400 {} \; find /var/backup/db* -type d -exec chmod 700 {} \; chmod a+x /etc/cron.daily/runmysqlbackup service crond restart ===== 出現的警告與異常訊息解法 ===== ==== 1. WARNING: Turning off multicore support, since pigz isn't there. ==== * 安裝 pigz 來解決 yum install pigz ==== 2.mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES ==== * 參數檔內的 CONFIG_mysql_dump_single_transaction 設為'yes' 來解決 : # While a --single-transaction dump is in process, to ensure a valid dump file (correct table contents and # binary log coordinates), no other connection should use the following statements: ALTER TABLE, CREATE TABLE, # DROP TABLE, RENAME TABLE, TRUNCATE TABLE. A consistent read is not isolated from those statements, so use of # them on a table to be dumped can cause the SELECT that is performed by mysqldump to retrieve the table # contents to obtain incorrect contents or fail. CONFIG_mysql_dump_single_transaction='yes' # http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html#option_mysqldump_master-data : ===== 參考網址 ===== * https://sourceforge.net/projects/automysqlbackup/ * http://www.ttwen.info/article/405332 * https://www.redeo.nl/2013/11/automysqlbackup-warning-using-password-command-line-interface-can-insecure/ {{tag>類型:系統備份 狀態:已發行 mysql backup}}