innobackupex命令还原时报错。
报错信息如下:
[mysql@ggg2 ~]$ innobackupex --defaults-file=/data/mysqldata/backup/2016-10-16_21-47-35/backup-my.cnf --copy-back /data/mysqldata/backup/2016-10-16_21-47-35
InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona Ireland Ltd 2009-2012. All Rights Reserved.
This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.
IMPORTANT: Please check that the copy-back run completes successfully.
At the end of a successful copy-back run innobackupex
prints "completed OK!".
Original data directory './' is not empty! at /usr/local/percona-xtrabackup-2.0.7/bin/innobackupex line 590.
1、在网上也找到一些类似错误的解决办法,但是都无效。
命令中通过 --defaults-file选项,指定了参数文件(备份的):/DATA/mysqldata/BACKUP/2016-10-16_21-47-35/BACKUP-my.cnf
于是查看了参数文件,内容如下:
# This MySQL options file was generated by innobackupex.
# The MySQL server
[mysqld]
innodb_data_file_path=ibdata1:2048M:autoextend
innodb_log_files_in_group=3
innodb_log_file_size=134217728
innodb_page_size=16384
innodb_undo_tablespaces=0
额,被innobackupex命令备份的参数文件给坑了,竟然没有datadir参数。
于是加了一行:datadir=/data/mysqldata/3306/data
再次运行命令,还是报错:
Original data directory '/data/mysqldata/3306/data' does not exist! at /usr/local/percona-xtrabackup-2.0.7/bin/innobackupex line 586.
[mysql@ggg2 ~]$ mkdir -p /data/mysqldata/3306/data
[mysql@ggg2 ~]$ ls -al /data/mysqldata/3306
总用量 12
drwxrwxr-x. 3 mysql mysql 4096 10月 18 22:44 .
drwxr-xr-x. 7 mysql mysql 4096 10月 18 22:44 ..
drwxrwxr-x. 2 mysql mysql 4096 10月 18 22:44 data
3、再次执行命令,还是报错了,不过这次是空间不足:
innobackupex: Error: copy failed: 设备上没有空间 at /usr/local/percona-xtrabackup-2.0.7/bin/innobackupex line 386.
看了一下,确实是没有剩余空间了,使用率100%了
![偷笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/titter.gif)
[root@ggg2 Desktop]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G 15G 0 100% /
tmpfs 936M 228K 936M 1% /dev/shm
/dev/sda1 194M 36M 148M 20% /boot
删了一些不需要的文件之后,再次执行命令,就成功了,这样就把之前所备份的文件还原到 数据目录中了:
161018 22:55:37 innobackupex: completed OK!
4、把参数文件复制到原来的目录:
[mysql@ggg2 ~]$ cp /data/mysqldata/backup/2016-10-16_21-47-35/backup-my.cnf /data/mysqldata/3306/my.cnf
然后,再my.cnf文件上再加上:
basedir = /usr/local/mysql
socket = /data/mysqldata/3306/mysql.sock
pid-file = /data/mysqldata/3306/mysql.pid
tmpdir = /data/mysqldata/3306/tmp
5、接下来,启动mysql,不过报错了,说tmp目录不存在,然后接着创建tmp目录,不过还是回报错:
2016-10-18 23:22:40 22909 [ERROR] InnoDB: auto-extending data file /data/mysqldata/3306/data/ibdata1
is of a different size 20163 pages (rounded down to MB) than specified in the .cnf file: initial 131072 pages,
max 0 (relevant if non-zero) pages!
6、一开始没有明白为什么会报这个错误,后来才发现,原来是mysql发现在数据目录下没有发现 ibdata,所以又新建了一个ibdata文件,于是就报那个错误了,于是接下来把ibdata文件和ib_logfile文件拷贝到数据目录下,
启动mysql,恢复正常。