innobackupex恢复时遇到三个错误:
错误信息:
1. innobackupex: Error: Original data directory '.' is not empty! at /usr/bin/innobackupex line 2162
2. innobackupex: Error: Original data directory '/db/mysql5.6/data' does not exist! at /usr/bin/innobackupex line 2141
3. innobackupex: Error: Cannot overwrite file: /db/mysql5.6/redo/ib_logfile1 at /usr/bin/innobackupex line 2177.
解决方法:
1.指定--defaults-file
2.创建datadir
3.删除ib_logfile*
错误重现:
1. 用innobackupex恢复时没指定参数defaults-file
$innobackupex --copy-back /home/mysqlweb/2014-10-27_14-57-31/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!".
innobackupex: Error: Original data directory '.' is not empty! at /usr/bin/innobackupex line 2162
$ls -l /db/mysql5.6/data
total 0
错误信息时Original data directory '.' is not empty,貌似mysql的datadir非空。
实际上这个目录是空的。原因是没有指定my.cnf的路径。
2.用innobackupex恢复时,datadir不存在
$innobackupex --defaults-file=/db/mysql5.6/my.cnf --copy-back /home/mysqlweb/2014-10-27_14-57-31/
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
Get the latest version of Percona XtraBackup, documentation, and help resources:
http://www.percona.com/xb/p
IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!".
innobackupex: Error: Original data directory '/db/mysql5.6/data' does not exist! at /usr/bin/innobackupex line 2141
原因:mysql的datadir目录不存在。
$ ll /db/mysql5.6/data
ls: cannot access /db/mysql5.6/data: No such file or directory
创建相关的datadir目录即可。
$ mkdir -p /db/mysql5.6/data
3. 用innobackupex恢复时,ib_logfile*文件未删除
$innobackupex --defaults-file=/db/mysql5.6/my.cnf --copy-back /home/mysqlweb/2014-10-27_14-57-31/
innobackupex: Starting to copy InnoDB log files
innobackupex: in '/home/mysqlweb/2014-10-27_14-57-31'
innobackupex: back to original InnoDB log directory '/db/mysql5.6/redo/'
innobackupex: Error: Cannot overwrite file: /db/mysql5.6/redo/ib_logfile1 at /usr/bin/innobackupex line 2177.
$ll /db/mysql5.6/redo
total 393216
-rw-r--r-- 1 mysqlweb mysql 134217728 2014-10-27 16:25:21 ib_logfile0
-rw-r--r-- 1 mysqlweb mysql 134217728 2014-10-27 16:25:21 ib_logfile1
-rw-r--r-- 1 mysqlweb mysql 134217728 2014-10-27 16:25:21 ib_logfile2
删除ib_logfile*文件后恢复正常。
$rm -rf ib_logfile*