我正在尝试使用 Percona XtraBackup 进行备份并收到以下错误:
[root@ads-dev1 ~]# innobackupex /root/db
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.
140722 11:52:16 innobackupex: Starting mysql with options: --unbuffered --
140722 11:52:16 innobackupex: Connected to database with mysql child process (pid=15930)
140722 11:52:22 innobackupex: Connection to database server closed
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".
innobackupex: Using mysql Ver 14.12 Distrib 5.0.95, for redhat-linux-gnu (x86_64) using readline 5.1
innobackupex: Using mysql server version Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
innobackupex: Created backup directory /root/db/2014-07-22_11-52-22
140722 11:52:22 innobackupex: Starting mysql with options: --unbuffered --
140722 11:52:22 innobackupex: Connected to database with mysql child process (pid=15953)
140722 11:52:24 innobackupex: Connection to database server closed
140722 11:52:24 innobackupex: Starting ibbackup with command: xtrabackup_51 --defaults-group="mysqld" --backup --suspend-at-end --target-dir=/root/db/2014-07-22_11-52-22 --tmpdir=/tmp
innobackupex: Waiting for ibbackup (pid=15959) to suspend
innobackupex: Suspend file '/root/db/2014-07-22_11-52-22/xtrabackup_suspended'
xtrabackup_51 version 2.0.8 for MySQL server 5.1.59 unknown-linux-gnu (x86_64) (revision id: 587)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql
xtrabackup: Target instance is assumed as followings.
xtrabackup: innodb_data_home_dir = ./
xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup: innodb_log_group_home_dir = ./
xtrabackup: innodb_log_files_in_group = 3
xtrabackup: innodb_log_file_size = 536870912
xtrabackup: using O_DIRECT
>> log scanned up to (94 3209639289)
140722 11:52:25 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.1/en/operating-system-error-codes.html
InnoDB: Error: could not open single-table tablespace file
InnoDB: ./roei_cc/transport.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: Error: ibbackup child process has died at /usr/bin/innobackupex line 386.
[root@ads-dev1 ~]#
我已经检查了文件的权限,但没有发现问题,我也尝试使用 mysql 用户运行该命令并得到相同的错误,甚至运行了下一个命令:
# ulimit -n 4096 ; innobackupex /root/db
但出现了完全相同的错误,有什么想法吗?
答案1
通过对错误代码 24 进行一些研究,这似乎是对任何一个用户可以打开的文件数量的限制。
您可以通过运行ulimit -Hn
和找到这些限制ulimit -Sn
。-Hn 是无法通过的限制,由 root 设置。
您必须提高打开文件数限制,直到错误消失。作为 root 用户,首先:ulimit -a
找到当前打开文件的最大数量,然后使用ulimit -n 2048
/ ulimit -n 4094
etc 设置新限制,可能以 2 的幂递增,直到找到适合您的实现的大小。
答案2
解决方案很简单,您可以将参数open-files-limit
直接传递给 xtrabackup 命令(以 root 身份运行):
# xtrabackup --backup --parallel=10 --target-dir=... --open-files-limit=100000
答案3
对于此问题,请增加 ulimit。首先检查ulimit -a,ulimit -Sn,ulimit -Hn 然后使用以下方法增加限制ulimit -n 10240 在我的例子中,更改 ulimit 后,Xtrabackup 命令运行正常
答案4
尝试设置 MySQL 的最大打开文件限制(使用ulimit -n 100000
):
[mysqld]
open-files-limit = 100000
(不要忘记重新启动 MySQL)