首页 > 代码库 > Innobackupex备份恢复
Innobackupex备份恢复
接到头的指示,要重新搭建一个沙箱环境,登陆目标库查看数据文件大小
[root@db180 mysql5_data3306]# du -sh 575G .
数据量貌似不小,使用xtrabackup备份比较好。
问题1、sh: xtrabackup_55: command not found
[root@db180 bin]# ./innobackupex-1.5.1 --defaults-file=/apps/conf/mysql/my3306.cnf --socket=/tmp/mysql3306.sock --user=root --password=‘xxxxxxx‘ /tmp/ 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 141028 10:02:34 innobackupex-1.5.1: Connecting to MySQL server with DSN ‘dbi:mysql:;mysql_read_default_file=/apps/conf/mysql/my3306.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql3306.sock‘ as ‘root‘ (using password: YES). 141028 10:02:34 innobackupex-1.5.1: Connected to MySQL server 141028 10:02:34 innobackupex-1.5.1: Executing a version check against the server... 141028 10:02:34 innobackupex-1.5.1: Done. IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex-1.5.1 prints "completed OK!". innobackupex-1.5.1: Using mysql server version 5.5.29-log sh: xtrabackup_55: command not found innobackupex-1.5.1: Error: no ‘mysqld‘ group in MySQL options at ./innobackupex-1.5.1 line 4357.
原因:
在/usr/bin目录下并没有找到xtrabackup的命令,innobackupex也会调用xrabackup [root@db180 bin]# cp xtrabackup_55 /usr/bin/
问题二、InnoDB: Error number 24 means ‘Too many open files‘.
解决innobackupex调用问题之后,继续执行命令
[root@db180 bin]# ./innobackupex-1.5.1 --defaults-file=/apps/conf/mysql/my3306.cnf --socket=/tmp/mysql3306.sock --user=root --password=‘xxxxxx‘ /tmp/ 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 141028 10:05:17 innobackupex-1.5.1: Connecting to MySQL server with DSN ‘dbi:mysql:;mysql_read_default_file=/apps/conf/mysql/my3306.cnf;mysql_read_default_group=xtrabackup;mysql_socket=/tmp/mysql3306.sock‘ as ‘root‘ (using password: YES). 141028 10:05:17 innobackupex-1.5.1: Connected to MySQL server 141028 10:05:17 innobackupex-1.5.1: Executing a version check against the server... 141028 10:05:17 innobackupex-1.5.1: Done. IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex-1.5.1 prints "completed OK!". innobackupex-1.5.1: Using mysql server version 5.5.29-log Warning: xtrabackup_55: ignoring option ‘--innodb_adaptive_hash_index‘ due to invalid value ‘ON‘ innobackupex-1.5.1: Created backup directory /tmp/2014-10-28_10-05-17 141028 10:05:17 innobackupex-1.5.1: Starting ibbackup with command: xtrabackup_55 --defaults-file="/apps/conf/mysql/my3306.cnf" --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/tmp/2014-10-28_10-05-17 --tmpdir=/apps/tmp innobackupex-1.5.1: Waiting for ibbackup (pid=8605) to suspend innobackupex-1.5.1: Suspend file ‘/tmp/2014-10-28_10-05-17/xtrabackup_suspended_2‘ Warning: xtrabackup_55: ignoring option ‘--innodb_adaptive_hash_index‘ due to invalid value ‘ON‘ xtrabackup_55 version 2.1.8 for Percona Server 5.5.35 Linux (x86_64) (revision id: 733) xtrabackup: uses posix_fadvise(). xtrabackup: cd to /apps/dbdat/mysql5_data3306 xtrabackup: using the following InnoDB configuration: xtrabackup: innodb_data_home_dir = /apps/dbdat/mysql5_data3306 xtrabackup: innodb_data_file_path = ibdata1:1000M:autoextend xtrabackup: innodb_log_group_home_dir = /apps/dbdat/mysql5_data3306 xtrabackup: innodb_log_files_in_group = 4 xtrabackup: innodb_log_file_size = 1048576000 141028 10:05:17 InnoDB: Using Linux native AIO xtrabackup: using O_DIRECT >> log scanned up to (4925507986513) >> log scanned up to (4925508083918) >> log scanned up to (4925508152373) >> log scanned up to (4925508254782) >> log scanned up to (4925508311389) >> log scanned up to (4925508404567) >> log scanned up to (4925508472282) 141028 10:05:24 InnoDB: Operating system error number 24 in a file operation. InnoDB: Error number 24 means ‘Too many open files‘. InnoDB: Some operating system error numbers are described at InnoDB: http://dev.mysql.com/doc/refman/5.5/en/operating-system-error-codes.html InnoDB: Error: could not open single-table tablespace file InnoDB: ./vip_stock_15/size_normal_list.ibd! InnoDB: We do not continue the crash recovery, because the table may become InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it. InnoDB: To fix the problem and start mysqld: InnoDB: 1) If there is a permission problem in the file and mysqld cannot InnoDB: open the file, you should modify the permissions. InnoDB: 2) If the table is not needed, or you can restore it from a backup, InnoDB: then you can remove the .ibd file, and InnoDB will do a normal InnoDB: crash recovery and ignore that table. InnoDB: 3) If the file system or the disk is broken, and you cannot remove InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf InnoDB: and force InnoDB to continue crash recovery here. innobackupex-1.5.1: Error: The xtrabackup child process has died at ./innobackupex-1.5.1 line 2622. [root@db180 bin]#
报错很多,但是要看第一个问题,后续的问题都会受第一个问题的干扰,open files,需要设置ulimit -n
[root@db180 bin]# ulimit -n 8000
好了,现在可以正常调用了
问题3:
文件很大,要如何压缩打包?
/apps/sh/tool/xtrabackup/bin/innobackupex-1.5.1 --defaults-file=/apps/conf/mysql/my3306.cnf --user=root --password=‘xxxxxxxxx‘ --socket=/tmp/mysql3306.sock --stream=tar /apps/tmp/xdbackup/ 2>/apps/tmp/xdbackup/2014-10-27.log |gzip >/apps/tmp/xdbackup/alldb20141027.tar.gz
实际备份完之后,检查压缩包大小
[root@db180 xdbackup]# ll -h alldb20141027.tar.gz -rw-r--r-- 1 root root 5.7G Oct 27 20:47 alldb20141027.tar.gz
怎么会只有这么点大?!
root@localhost : (none) 09:53:14> select concat(round(sum(DATA_LENGTH/1024/1024), 2), ‘MB‘) as data from information_schema.TABLES; +------------+ | data | +------------+ | 25722.81MB | +------------+ 原来数据库实际数据大小只有25G
虚惊一场。
现在把压缩后的5.7G的小文件拷贝到服务器上恢复。
解压压缩包:需要添加 -i参数 [root@localhost tmp]# tar ivzxf alldb20141027.tar.gz 应用日志:apply-log /apps/sh/tool/xtrabackup/bin/innobackupex-1.5.1 --defaults-file=/apps/conf/mysql/mysql5_3306.cnf --ibbackup=xtrabackup_55 --user=root --password=‘xxxxxxx‘ --apply-log /apps/tmp/full/ 把完整的数据文件copy-back [root@localhost full]# /apps/sh/tool/xtrabackup/bin/innobackupex-1.5.1 --defaults-file=/apps/conf/mysql/mysql5_3306.cnf --ibbackup=xtrabackup_55 --user=root --password=‘xxxxxxx‘ --copy-back /apps/tmp/full/ ... ... ... innobackupex-1.5.1: Starting to copy InnoDB log files innobackupex-1.5.1: in ‘/apps/tmp/full‘ innobackupex-1.5.1: back to original InnoDB log directory ‘/apps/dbdat/mysql5_data3306‘ innobackupex-1.5.1: Copying ‘/apps/tmp/full/ib_logfile0‘ to ‘/apps/dbdat/mysql5_data3306/ib_logfile0‘ innobackupex-1.5.1: Copying ‘/apps/tmp/full/ib_logfile1‘ to ‘/apps/dbdat/mysql5_data3306/ib_logfile1‘ innobackupex-1.5.1: Copying ‘/apps/tmp/full/ib_logfile2‘ to ‘/apps/dbdat/mysql5_data3306/ib_logfile2‘ innobackupex-1.5.1: Copying ‘/apps/tmp/full/ib_logfile3‘ to ‘/apps/dbdat/mysql5_data3306/ib_logfile3‘ innobackupex-1.5.1: Finished copying back files. 141028 10:59:49 innobackupex-1.5.1: completed OK!
拷贝回来之后,文件全是root权限:
需要更改权限之后重启数据库。
Innobackupex备份恢复
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。