最近使用innobackupex這個備份工具,使用了--tables-file參數,原命令如下:
/usr/bin/innobackupex --no-timestamp --user='xxx' --password='xxxx' --rsync --compress --compress-threads=5 --compress-chunk-size=64K --slave-info --tables-file=/data/deploy/mysql_backup/tables.txt /data/deploy/mysql_backup/backup_dir/full
報錯:
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
191101 11:26:49 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;port=3306;mysql_socket=/var/run/mysqld/mysqld.sock' as 'bkpuser' (using password: YES).
191101 11:26:49 version_check Connected to MySQL server
191101 11:26:49 version_check Executing a version check against the server...
191101 11:26:49 version_check Done.
191101 11:26:49 Connecting to MySQL server host: localhost, user: bkpuser, password: set, port: 3306, socket: /var/run/mysqld/mysqld.sock
Using server version 5.6.44-86.0-log
/usr/bin/innobackupex version 2.3.10 based on MySQL server 5.6.24 Linux (x86_64) (revision id: bd0d4403f36)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /data/mysqldb
xtrabackup: open files limit requested 0, set to 655350
xtrabackup: using the following InnoDB configuration:
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:100M:autoextend
xtrabackup: innodb_log_group_home_dir = /data/mysqldb/
xtrabackup: innodb_log_files_in_group = 3
xtrabackup: innodb_log_file_size = 268435456
xtrabackup: using O_DIRECT
xtrabackup: `mysql.user...` name is too long
發現mysql.user表長度,字段長度並無異常,且是mysql自動維護的表,不應該會有錯誤。
於是檢查/data/deploy/mysql_backup/tables.txt文件,發現也並無異常,每行一個表。
經過測試發現每次都是最後一行的表名提示報錯。於是查看 xtrabackup 源碼:
發現xtrabackup工具對於每一行都會去查找“\n”, 即使是最後一行,也要求末尾有"\n",否則指定 --tables-file 參數就會報錯。
於是在 生成的tables.txt內容最後一行添加"\n", 測試問題解決。