How to solve the problem of the number of files opened by MySQL in Linux

Source: Internet
Author: User

The error message is as follows:
.....
070813 13:10:17 [ERROR]/usr/local/mysql/bin/mysqld: Can't open file: './yejr/access. frm' (errno: 24)
070813 13:10:17 [ERROR]/usr/local/mysql/bin/mysqld: Can't open file: './yejr/accesslog. frm' (errno: 24)
......
070813 13:10:17 [ERROR] Error in accept: Too open files
....

Note that the system error code is 24. Use perror to check the specific error information:

[Root @ yejr] #/usr/bin/perror 24
OS error code 24: Too enabled open files

It turns out that too many files are opened, which is easy to handle. Use sysctl to adjust it:
[Root @ yejr] # sysctl-w fs. file-max = 43621
[Root @ yejr] # sysctl-a | grep fs. file-max
Fs. file-max = 43621

Sysctl is also used to adjust FreeBSD:
[Root @ yejr] # sysctl-w kern. maxfiles = 123280
[Root @ yejr] # sysctl-a | grep kern. maxfiles
Kern. maxfiles = 123280

Finally, the most important thing is to modify the mysqld configuration file my. cnf and add the following line:

Open_files_limit = 4096
# Adjust the value as needed. The default value is
# Max_connections * 5 or max_connections + table_cache * 2

Then, restart mysqld as root. here, even though my. the running user specified in cnf is not the root user. You can also start mysqld as the root user. Otherwise, the open_files_limit option cannot take effect because the kernel limits the maximum number of files opened by normal users.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.