# How to get Percona Server 5.7 respect open files limit?

**URL:** <https://forums.percona.com/t/how-to-get-percona-server-5-7-respect-open-files-limit/6798>\
**Category:** Percona Server for MySQL 5.7\
**Created:** [January 15, 2019, 4:33pm UTC](https://forums.percona.com/t/how-to-get-percona-server-5-7-respect-open-files-limit/6798 "2019-01-15T16:33:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeonardChallis](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/leonardchallis/32/1163_2.png) [@LeonardChallis](https://forums.percona.com/u/LeonardChallis)\
**Post date:** [January 15, 2019, 4:33pm UTC](https://forums.percona.com/t/how-to-get-percona-server-5-7-respect-open-files-limit/6798/1 "2019-01-15T16:33:53Z")

</div>

My system:

```auto
Linux x.x.x.x.hostname 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

```

I am seeing errors like:

```auto
mysqldump: Got error: 23: Out of resources when opening file './someschema/somerelation.MYD' (Errcode: 24 - Too many open files) when using LOCK TABLES

```

from my cron output on some backup scripts. Reading into this I believe it’s because I need to up the open files limit. Currently it is 5000:

```auto
mysql> select &#64;&#64;open_files_limit;
+--------------------+
| &#64;&#64;open_files_limit |
+--------------------+
| 5000 |
+--------------------+
1 row in set (0.00 sec)

```

I was reading about the bug where open file limits are ignored in 5.7 ([url][[PS-1796] LP #1673712: Open files limit no longer applied after in place upgrade from 5.6 to 5.7 - Percona JIRA](https://jira.percona.com/browse/PS-1796?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel%5B/url%5D)) and the work around there and also referenced in the Percona blog post about it ([url][https://www.percona.com/blog/2017/10/12/open\_files\_limit-mystery/[/url]](https://www.percona.com/blog/2017/10/12/open_files_limit-mystery/%5B/url%5D)) and so I tried to bump these up to huge values to test - this is what I’ve done:

/etc/security/limits.conf:

```auto
* soft nofile 1024000
* hard nofile 1024000
* soft nproc 10240
* hard nproc 10240

$ ulimit -n
1024000

```

I’m not sure if it’s actually needed, after reading those links above, but in the [mysqld] section of my MySQL conf (/etc/percona-server.conf.d/mysqld.cnf) I also have:

```auto
open-files-limit=1024000

```

After restarting, my open files limit in MySQL is still 5000. When I look at the limits…

```auto
[root&#64;yoshi ~]# systemctl status mysql.service | grep PID
Main PID: 31668 (mysqld)
[root&#64;yoshi ~]# cat /proc/31668/limits | grep files
Max open files 5000 5000 files

```

In the blog post it says:

You also need to have a row session required pam\_limits.so in the file /etc/pam.d/common-session.

I don’t actually see a file called /etc/pam.d/common-session anywhere though. I read somewhere that the alternative on Cents 7 is etc/pam.d/system-auth. In that file I see:

```auto
session required pam_limits.so

```

So I presumed this should now work. I’ not sure where to go from here, can anyone advise how I can make Percona take the open files limit into account (or indeed, properly set the open files limit of the system?)

Thanks

---

<div class="post-metadata">

**Author:** ![LeonardChallis](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/leonardchallis/32/1163_2.png) [@LeonardChallis](https://forums.percona.com/u/LeonardChallis)\
**Post date:** [January 16, 2019, 2:02am UTC](https://forums.percona.com/t/how-to-get-percona-server-5-7-respect-open-files-limit/6798/2 "2019-01-16T02:02:54Z")

</div>

So it looks like I finally came across the correct solution. But if someone has any comments on this that’d be great.

```auto
[root&#64;yoshi ~]# find / -type f -name mysqld.service
/usr/lib/systemd/system/mysqld.service
[root&#64;yoshi ~]# vim /usr/lib/systemd/system/mysqld.service # changed LimitNOFILE = 5000 to LimitNOFILE = 1024000
[root&#64;yoshi ~]# systemctl daemon-reload
[root&#64;yoshi ~]# systemctl restart mysql.service
[root&#64;yoshi ~]# mysql -e "show global variables like 'open%';"
+------------------+---------+
| Variable_name | Value |
+------------------+---------+
| open_files_limit | 1024000 |
+------------------+---------+

```
