MySQL Variables open_files_limit 数据库 参数变量解释及正确配置使用
本站中文解释
open_files_limit参数能够控制MySQL进程能够打开的文件数量。它能够控制全局变量 max_open_files 的值,确保MySQL能够正确地打开所需要数量的文件。
要设置open_files_limit参数,需要编辑MySQL配置文件my.cnf,在[mysqld]部分添加 open_files_limit = N (N为你想要设置的数字), 然后运行show variables like ‘open_files_limit’ 命令来查看已设置的参数值。
官方英文解释
open_files_limit
Command-Line Format | --open-files-limit=# |
---|---|
System Variable | open_files_limit |
Scope | Global |
Dynamic | No |
Type | Integer |
Default Value | 5000, with possible adjustment |
Minimum Value | 0 |
Maximum Value | platform dependent |
The number of file descriptors available to
mysqld from the operating system:
-
At startup, mysqld reserves descriptors
withsetrlimit()
, using the value
requested at by setting this variable directly or by using
the--open-files-limit
option to mysqld_safe. If
mysqld produces the errorToo
, try increasing the
many open files
open_files_limit
value.
Internally, the maximum value for this variable is the
maximum unsigned integer value, but the actual maximum is
platform dependent. -
At runtime, the value of
open_files_limit
indicates the number of file descriptors actually
permitted to mysqld by the operating
system, which might differ from the value requested at
startup. If the number of file descriptors requested
during startup cannot be allocated,
mysqld writes a warning to the error
log.
The effective
open_files_limit
value is
based on the value specified at system startup (if any) and
the values of max_connections
and table_open_cache
, using
these formulas:
-
10 + max_connections + (table_open_cache *
2) -
max_connections * 5
-
The operating system limit if that limit is positive but
not Infinity. -
If the operating system limit is Infinity:
open_files_limit
value if specified at
startup, 5000 if not.
The server attempts to obtain the number of file descriptors
using the maximum of those values. If that many descriptors
cannot be obtained, the server attempts to obtain as many as
the system permits.
The effective value is 0 on systems where MySQL cannot change
the number of open files.
On Unix, the value cannot be set greater than the value
displayed by the ulimit -n command. On
Linux systems using systemd
, the value
cannot be set greater than LimitNOFile
(this is DefaultLimitNOFILE
, if
LimitNOFile
is not set); otherwise, on
Linux, the value of open_files_limit
cannot
exceed ulimit -n.