接到頭的指示,要從新搭建一個沙箱環境,登錄目標庫查看數據文件大小html
[root@db180 mysql5_data3306]# du -sh 575G .
數據量貌似不小,使用xtrabackup備份比較好。mysql
問題一、sh: xtrabackup_55: command not foundsql
[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.
緣由:shell
在/usr/bin目錄下並無找到xtrabackup的命令,innobackupex也會調用xrabackup [root@db180 bin]# cp xtrabackup_55 /usr/bin/
問題2、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 -napp
[root@db180 bin]# ulimit -n 8000
好了,如今能夠正常調用了
socket
問題3:spa
文件很大,要如何壓縮打包?rest
/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權限:
須要更改權限以後重啓數據庫。