Mysql 无法在centos7上增加mariadb 10中打开的文件限制

Mysql 无法在centos7上增加mariadb 10中打开的文件限制,mysql,mariadb,Mysql,Mariadb,我搜索了主题主题并测试了选项,但我仍然无法增加mariadb服务器上的打开文件限制,该服务器用作cpanel/whm服务器的远程数据库服务器。 这是很好的参考资料 我把它增加了 /etc/my.cnf open-files-limit=65550 下面是一些结果 #ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited sche

我搜索了主题主题并测试了选项,但我仍然无法增加mariadb服务器上的打开文件限制,该服务器用作cpanel/whm服务器的远程数据库服务器。 这是很好的参考资料

我把它增加了

/etc/my.cnf 

open-files-limit=65550
下面是一些结果

#ulimit -a 
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 63471
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 65535
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
最大用户进程数(-u)65535 虚拟内存(KB,-v)不受限制 文件锁(-x)无限制

#ulimit -Hn -Sn                              
open files                      (-n) 65535
open files                      (-n) 65535

cat /etc/systemd/system/mariadb.service.d/limits.conf 
[Service]
LimitNOFILE=65500

cat /usr/lib/systemd/system/mariadb.service

[Unit]
Description=MariaDB database server
After=syslog.target
After=network.target

[Service]
Type=simple
User=mysql
Group=mysql
LimitNOFILE=infinity
LimitMEMLOCK=infinity
在mysql中,我仍然可以

显示全局变量,如“打开%”

+------------------+-------+

|变量名称|值|

+------------------+-------+

|打开|文件| 1024|

+------------------+-------+

一行一组(0.00秒)

在重新启动后,我一遍又一遍地出现以下错误

60108 16:30:02 [ERROR] mysqld: Can't open file: './username_wp/wp_users.frm' (errno: 24)
160108 16:30:02 [ERROR] Error in accept: Too many open files
160108 16:30:04 [ERROR] Error in accept: Too many open files
160108 16:30:06 [ERROR] Error in accept: Too many open files
160108 16:30:11 [ERROR] mysqld: Can't open file: './username_db/strikes.frm' (errno: 24)
这是mariadb的启动日志

[Warning] Could not increase number of max_open_files to more than 1024 (request: 132107)
这是一个操作系统问题

我认为您必须增加
/etc/security/limits.conf
中的“硬限制”,如下所示:

* hard nofile 65536
* soft nofile 16384

然后使用
ulimit
增加“软限制”

最终我找到了解决方案,但没有任何合理的原因! 我正在运行MariaDB 5.5和所有设置,但软限制没有超过1024! 我想我的mariadb是10.0,因为我刚刚安装了它

在我发现它是5.5版本后,我尝试将它升级到v10.0!然后砰的一声!无需任何额外操作或设置即可解决问题(内核设置允许最大文件限制,如参考链接中所述)


我希望它能帮助其他人解决同样的问题(但在尝试所有其他必需的设置之后)

您可以在mariadb.service文件中看到官方说明

[root@db1 system]# cat /usr/lib/systemd/system/mariadb.service | grep exam -A 5
# For example, if you want to increase mariadb's open-files-limit to 10000,
# you need to increase systemd's LimitNOFILE setting, so create a file named
# "/etc/systemd/system/mariadb.service.d/limits.conf" containing:
#       [Service]
#       LimitNOFILE=10000

虽然我认为这应该写在…

RH/CentOS中,但mariadb的集成非常混乱,在某些地方使用mariadb作为其名称,在其他地方使用mysqld…
您应该在中编辑(或创建)一个.conf文件 /etc/systemd/system/mariadb.service.d/ 例如:/etc/systemd/system/mariadb.service.d/centreon.conf

然后按照库吉的建议编辑它

[Service]
LimitNOFILE=320000
不要忘记重新加载systemd services文件:

#systemctl后台程序重新加载


Cedric

我从安装了CentOS 7.3和MariaDB 10.0.29

出于某种原因,systemd单元名为
mysql
,我必须创建
/etc/systemd/system/mysql.service.d/oioki.conf

[Service]
LimitNOFILE=500000

别忘了在那之后运行
systemctl守护进程重载

我在运行带有软件集合(SCL)和SystemD的RedHat Enterprise Linux 7.2时遇到了这个问题

rh-mariadb100-mariadb-server-10.0.20-1.el7.x86_64
在我的例子中,硬限制是可以的,但软限制被固定在1024

新老问题综述

old : RHEL6.x : MySQL : init.d : mysql_safe : 'root', mysqld : 'mysql'
new : RHEL7.x : MariaDB : SystemD : mysql_safe : 'mysql', mysqld 'mysql'
请注意,旧的initl.d包装器脚本作为root运行,而新的SystemD包装器脚本作为“mysql”运行。这可能会导致mysql\u safe不调用ulimit。在我的例子中,在SystemD中设置LimitNOFILE没有帮助——它所做的只是增加包装器的文件限制,而不是守护进程本身。 我找到了一个两步的过程来让它工作

步骤1-将mysqld_-safe部分重新安装到conf文件中,以便mysql_-safe读取它

sudo vi /etc/opt/rh/rh-mariadb100/my.cnf.d/mariadb-server.cnf
[mysqld_safe]
open_files_limit=2048
步骤2-创建一个SystemD插件,以root身份启动包装器(守护进程仍将以“mysql”身份运行)。请注意,LimitNOFILE已被注释掉

/etc/systemd/system
mkdir rh-mariadb100-mariadb.service.d
cd rh-mariadb100-mariadb.service.d
vi limits.conf
[Service]
#LimitNOFILE=2048
User=
Group=
重新加载SystemD服务文件

systemctl daemon-reload
现在重新启动服务,在mysql客户端中检查open_files_limit的值 现在应该是2048(新的软限制)

正确的解决方案可能是去掉包装器并使用原生SystemD

更新 看起来这在最近的版本中已经修复,不再使用mysql\u安全包装器

rh-mariadb101-mariadb-10.1.19-6.el7.x86_64

要在Centos 7上增加MySQL 5.6中的打开文件限制,您必须:

nano /usr/lib/systemd/system/mysqld.service
在文件末尾添加:

LimitNOFILE=65535
LimitNPROC=65535
然后:


好了,我假设对于MariaDB来说也是一样的

open\u files\u limit
是动态值,取决于下一个参数:

#my.cnf file

# max connections
max_connections = 64
# table_open_cache = max_connections * tables used in one transaction + 5
table_open_cache = 800
# table_definition_cache = all tables(50) + max_connections + 5
table_definition_cache = 400
# open_files_limit = table_open_cache * 1.4
open_files_limit = 1120
要检查
open\u files\u limit
的值,请从mysql运行以下命令:

mysql>select@@open\u files\u limit;
…它将输出:

+--------------------+
| @@open_files_limit |
+--------------------+
|              12903 |
+--------------------+
1 row in set (0.000 sec)

你好感谢您的支持,我们增加了
code
cat/etc/security/limits.conf
code
mysql-soft-nofile 65535
code
mysql-hard-nofile 65535
code>*soft-nproc 65535
code
*soft nofile 65535
code
*hard-nofile 65535
code
,但问题仍然存在您是否更改了ulimit
ulimit
?选中“显示变量,如“表%”;这是ulimit的输出;现在,让我们看看重新启动mariadb服务器后新的
显示的
。问题仍然存在160211 16:30:02[警告]无法将最大打开文件数增加到1024个以上(请求:141323)。您可以使用
systemd edit
编辑systemd服务,这将为您提供一个空白文件。添加上面的内容,这将覆盖分发的主服务文件。我想这就是这里所建议的,但是使用
systemd edit…
可以避免为发行版找到正确位置的猜测。
+--------------------+
| @@open_files_limit |
+--------------------+
|              12903 |
+--------------------+
1 row in set (0.000 sec)