cannot increase open-files-limit in mariadb 10 on centos7

不想你离开。 提交于 2020-11-29 09:17:09

问题


I searched about the topic subject and tested options, but I still cant increase the open-files-limit on my mariadb server that is used as remote database server for cpanel/whm server. here is s good reference http://duntuk.com/how-raise-ulimit-open-files-and-mysql-openfileslimit

I increased it in

/etc/my.cnf 

open-files-limit=65550

here is some results

#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

max user processes (-u) 65535 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited

#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

and still in mysql I get

show global variables like 'open%';

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

| Variable_name | Value |

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

| open_files_limit | 1024 |

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

1 row in set (0.00 sec)

and im getting following error over and over after restart

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)

and here is the startup log of mariadb

[Warning] Could not increase number of max_open_files to more than 1024 (request: 132107)

回答1:


RH/CentOS mariadb integration is quiet confusing, using in some places mariadb as its name, mysqld elsewhere...
You should edit(or create) a .conf file in /etc/systemd/system/mariadb.service.d/ For eg: /etc/systemd/system/mariadb.service.d/centreon.conf

Then edit it as kujiy suggested

[Service]
LimitNOFILE=320000

Don't forget to reload systemd services files:

# systemctl daemon-reload

Cedric




回答2:


This is an OS problem.

I think you have to increase the "hard limit" in /etc/security/limits.conf, something like this:

* hard nofile 65536
* soft nofile 16384

then use ulimit to increase the "soft limit".




回答3:


finally i find solution but without any reasonable cause ! i was running MariaDB 5.5 and all settings where fine but the soft limit did not goes more than 1024 ! i was thinking my mariadb is 10.0 as i freshly installed it

after i find out that its 5.5 i tried to upgrade it to v10.0 ! and then BOOM ! problem solved without any extra action or setting ( kernel setting allows maximum files limit as described in reference link )

i hope it help other peoples have same problem ( but after try all other required settings )




回答4:


You can see the official instruction in the mariadb.service file;

[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

Though I think this should be written in the official manual...




回答5:


I have CentOS 7.3 with MariaDB 10.0.29 installed from official repo.

For some reason, systemd unit is named mysql and I had to create /etc/systemd/system/mysql.service.d/oioki.conf:

[Service]
LimitNOFILE=500000

Don't forget to run systemctl daemon-reload after that.




回答6:


I had this problem running RedHat Enterprise Linux 7.2 with Software Collections (SCL) and SystemD

rh-mariadb100-mariadb-server-10.0.20-1.el7.x86_64

In my case the hard limit was ok, but the soft limit was stuck on 1024

Summary of the old and new

old : RHEL6.x : MySQL : init.d : mysql_safe : 'root', mysqld : 'mysql'
new : RHEL7.x : MariaDB : SystemD : mysql_safe : 'mysql', mysqld 'mysql'

Note that the old initl.d wrapper script runs as root, but the new SystemD wrapper script runs as 'mysql'. This can cause mysql_safe to not make the call to ulimit. In my case setting LimitNOFILE in SystemD didn't help - all it did was increase the file limit for the wrapper, but NOT for the daemon itself. I found a two step process to get it working

Step 1 - re-instate the mysqld_safe section to the conf file so that mysql_safe will read it

sudo vi /etc/opt/rh/rh-mariadb100/my.cnf.d/mariadb-server.cnf
[mysqld_safe]
open_files_limit=2048

Step 2 - create a SystemD drop-in to start the wrapper as root (the daemon will still run as 'mysql'). Note that LimitNOFILE is commented out.

/etc/systemd/system
mkdir rh-mariadb100-mariadb.service.d
cd rh-mariadb100-mariadb.service.d
vi limits.conf
[Service]
#LimitNOFILE=2048
User=
Group=

Reload SystemD service files

systemctl daemon-reload

now restart the service, check value of open_files_limit in mysql client it should now say 2048 (new soft limit)

The proper solution would probably be to get rid of the wrapper and use native SystemD.

UPDATE it looks like this is fixed in the more recent version, which no longer uses the mysql_safe wrapper

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



回答7:


To increase open-files-limit in MySQL 5.6 on Centos 7 you must:

nano /usr/lib/systemd/system/mysqld.service

add at the end of the file:

LimitNOFILE=65535
LimitNPROC=65535

then:

systemctl daemon-reload
systemctl restart mysqld

Done! , I assume that for MariaDB is the same thing




回答8:


open_files_limit is dynamic value that depends on next params:

#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

To check the value of open_files_limit run this command from mysql:

mysql> select @@open_files_limit;

...it will output:

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


来源:https://stackoverflow.com/questions/34686072/cannot-increase-open-files-limit-in-mariadb-10-on-centos7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!