MySQL open_files_limit-无法更改此变量


17

我遇到了问题,因为我open_files_limit的mysql仅适用于1024

Centos 7,MySQL Community Server 5.6.22-日志

实际上,这是WHM服务器专用于mysql的vps(远程mysql),但这不重要。


配置文件

my.cnf

[mysqld]
open_files_limit = 100000
open-files-limit = 100000 #I've read that the dashes are required on older versions, but I threw it in anyway.
innodb_buffer_pool_size = 600M
...

# and the same for mysqld_safe
[mysqld_safe]
open_files_limit = 100000
open-files-limit = 100000
...

/etc/security/limits.conf

*       hard    nofile  100000
*       soft    nofile  100000

命令输出

我的root操作系统open_files_limit:

[root@mack ~]# ulimit -Hn -Sn
open files                      (-n) 100000
open files                      (-n) 100000

然后以mysql用户身份:

[root@mack ~]# su mysql
bash-4.2$ ulimit -Hn -Sn
open files                      (-n) 100000
open files                      (-n) 100000

MySQL状态:

[root@mack ~]# service mysql status
Redirecting to /bin/systemctl status  mysql.service
mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: active (running) since Wed 2014-12-24 10:41:09 EST; 40min ago
  Process: 2982 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 2970 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 2981 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ââ2981 /bin/sh /usr/bin/mysqld_safe
           ââ3268 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --open-files-limit=100000 --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/my...

Dec 24 10:41:08 mack systemd[1]: Starting MySQL Community Server...
Dec 24 10:41:09 mack mysqld_safe[2981]: 141224 10:41:09 mysqld_safe Logging to '/var/log/mysqld.log'.
Dec 24 10:41:09 mack mysqld_safe[2981]: 141224 10:41:09 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Dec 24 10:41:09 mack systemd[1]: Started MySQL Community Server.

我重新启动了mysql,已停止,检查状态以确保它已停止,然后启动它,然后重新启动了整个系统。

有效的证据my.cnf

mysql> show global variables like '%buffer_pool_size%';
+-------------------------+-----------+
| Variable_name           | Value     |
+-------------------------+-----------+
| innodb_buffer_pool_size | 629145600 |
+-------------------------+-----------+
1 row in set (0.00 sec)

现在这是我的血压上升的地方:

mysql> show global variables like 'open%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| open_files_limit | 1024  |
+------------------+-------+
1 row in set (0.00 sec)

我想念什么?还有另一个my.cnf覆盖我的价值吗?

[root@mack ~]# find / -name "*.cnf"
/usr/share/mysql/my-default.cnf
/usr/share/doc/mysql-community-server-5.6.22/my-default.cnf
/var/lib/mysql/auto.cnf
/etc/my.cnf
/etc/pki/tls/openssl.cnf

我调查了所有这些内容,没有提到open_files_limit。对于它的麻烦,我grep通过这些寻找设置:

[root@mack ~]# grep -r "open_files_limit" /etc
/etc/my.cnf:open_files_limit = 100000
/etc/my.cnf:open_files_limit = 100000
[root@mack ~]# grep -r "open_files_limit" /var
[root@mack ~]# grep -r "open_files_limit" /usr
/usr/share/vim/vim74/syntax/ora.vim:syn keyword oraKeywordUnd     _number_cached_attributes _offline_rollback_segments _open_files_limit
Binary file /usr/sbin/mysqld matches
Binary file /usr/sbin/mysqld-debug matches
Binary file /usr/bin/mysqlbinlog matches
/usr/bin/mysqld_safe:      --open_files_limit=*) open_files="$val" ;;

但是不,它们不会影响它。


1
下面是从mysql日志重启时的珍闻:2014-12-24 10:41:09 3268 [Warning] Buffered warning: Could not increase number of max_open_files to more than 1024 (request: 100000)。这必须表示MySQL正在尝试增加其限制。
user24601 2014年

Answers:


18

我需要编辑/usr/lib/systemd/system/mysqld.service和添加

LimitNOFILE=infinity
LimitMEMLOCK=infinity

然后运行systemctl daemon-reloadsystemctl restart mysql.service

现在,65536由于某种原因,该变量的上限是未知的,但我现在可以接受。

/unix/152186/mysql-max-open-files-more-than-1024#answer-157910找到了


4
/ usr / lib /文件包含一个警告,请不要编辑它。对于Centos7上的MariaDB,我在创建了一个文件,/etc/systemd/system/mariadb.service.d/limits.conf其内容如下 [Service] LimitNOFILE=infinity LimitMEMLOCK=infinity
Chris Wheeler
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.