使用 XtraBackup 进行MySQL数据库物理备份(8)

innobackupex version 2.3.2 based on MySQL server 5.6.24 Linux (i686) (revision id: 306a2e0)
xtrabackup: cd to /backup/xtrabackup/full
xtrabackup: Error: cannot open ./xtrabackup_checkpoints
xtrabackup: error: xtrabackup_read_metadata()
xtrabackup: This target seems not to have correct metadata...
2015-11-06 10:41:48 b771e6d0  InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
xtrabackup: Warning: cannot open ./xtrabackup_logfile. will try to find.
2015-11-06 10:41:48 b771e6d0  InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
  xtrabackup: Fatal error: cannot find ./xtrabackup_logfile.
xtrabackup: Error: xtrabackup_init_temp_log() failed.

--apply-log会调用 xtrabackup --prepare两次,第一次前滚和回滚,第二次生成iblogfile[0|1]

[root@localhost ~]# innobackupex --apply-log /backup/xtrabackup/full/2015-11-05_22-38-55/ --user=bkpuser --password=digdeep

View Code

3.3 恢复 --copy-back

直接将上面prepare好的所有文件,复制到mysqld的datadir目录(会读取my.cnf中的配置信息)。

--copy--back的注意事项:

1> datadir必须是空的,或者使用--force-non-empty-directories选项;

2> mysqld必须关闭,如果是--import部分恢复,则不能关闭;

3> --copy-back完成之后,需要修改datadir目录下的文件权限: chown -R mysql:mysql /var/lib/mysql

[root@localhost ~]# mysqladmin -uroot -pxxx shutdown (关闭mysqld)

[root@localhost ~]# cd /var/lib/mysql

[root@localhost mysql]# ls

aazj        ib_logfile1        mysql-bin.000003  mysql-bin.000008  mysql-bin.000013  performance_schema

auto.cnf    localhost-slow.log  mysql-bin.000004  mysql-bin.000009  mysql-bin.000014  t

general.log  mysql              mysql-bin.000005  mysql-bin.000010  mysql-bin.000015  xtrabackup_binlog_pos_innodb

ibdata1      mysql-bin.000001    mysql-bin.000006  mysql-bin.000011  mysql-bin.000016  xtrabackup_info

ib_logfile0  mysql-bin.000002    mysql-bin.000007  mysql-bin.000012  mysql-bin.index

[root@localhost mysql]# mv * /backup/xtrabackup/  (进行清空)

[root@localhost mysql]# ls

[root@localhost mysql]# innobackupex --copy-back /backup/xtrabackup/full/2015-11-05_22-38-55/ --user=bkpuser --password=digdeep

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/656593acf3a21794ce9642049b430016.html