MySQL open_files_limit value change is invalid

Source: Internet
Author: User

A problem with the database displays too many files, causing the database to be inaccessible. The problem is that the file descriptor has been opened too large. The results of the database search are:

Show variables like "%file%";
Open_files_limit | 1024

To view the value of the system Ulimit:

[Email protected] ~]# ulimit-n65535

The value of the system is correct. Then modify the/ETC/MY.CNF configuration file to add

open_files_limit=65535

Then restart MySQL

Systemctl Restart MySQL

Check the MySQL values again:

Show variables like "%file%";
Open_files_limit | 1024

Still, this does not take effect. What's the problem. Depressed. After a constant attempt, suddenly found not to use the system's own command restart

[Email protected] system]# Mysqld_safe--defaults-file=/etc/my.cnf &

If this starts, the value of the setting is applied. The Ulimit value inside the script is not considered to be 65535.

Found a way to verify the operation.

Because MySQL boot will definitely invoke the Mysqld_safe script file, it will be verified in this file.

759 echo ' ulimit-n ' >>/tmp/1.txt #新加的调试内容760 ulimit-n 65535 #新加的调试内容761 echo ' Ulimit-n ' >& Gt /tmp/1.txt #新加的调试内容762 763 cmd= "' Mysqld_ld_preload_text ' $NOHUP _niceness" 764 765 for I in "$ledir/$MYSQLD" "--basedir= $M Y_basedir_version "766"--datadir= $DATADIR ""--plugin-dir= $plugin _dir "" $USER _option "

Use

[Email protected] ~]# Tailf/tmp/1.txt

Restart MySQL to watch the changes in the file's data.

10241024

Altogether has been 1024 and has not been set up with commands.

What the hell is going on here?

Write your own simple test script test Ulimit-n The value of the display is the system settings, why the MySQL can not call the system in the boot.

After finding the information. It is said that if the daemon is started by the shell, the Ulimit-n settings will not take effect. I don't know if it's right. For the moment, I think this MySQL startup is the script file called by a daemon. What should I do then?

Inadvertently saw the settings for the Redis startup file.

[[email protected] redis.service.d]# cat/etc/systemd/system/redis.service.d/limit.conf # If you need to change Max Open F Ile limit# For example if you change maxclient in configuration# you can change the Limitnofile value below# see ' Man S Ystemd.exec "for information[service]limitnofile=10240

This is set limit_files number of, according to gourd painting scoop, in the MySQL boot configuration file added.

[[email protected] system]# cat-n/etc/systemd/system/mysql.service 26[service] 27user=mysql 28group=mysql 29 # Execute pre and post scripts as root 31limitnofile=65535 #新加入的内容

And then continue

[Email protected] ~]# Tailf/tmp/1.txt

Restart MySQL to watch file changes

6553565535

Altogether took effect. Enter MSYQL, query result:

Mysql> Show variables like "%file%"; | open_files_limit | 65535

Successfully entered into force.

It shows that this parameter plays a role, and the Ulimit-n setting in the script is actually useless.


Summary: The personal feel of the system comes with the boot program is really convenient, but it will let the user does not know the actual invocation of the startup file work mode. If you encounter problems, it is best to find the source code to start the debugging, you will find a lot of unexpected things. and the official shell script that looks really fucking complicated.

This article is from "Who do you think I am" blog, please be sure to keep this source http://whhhj.blog.51cto.com/9289395/1787028

MySQL open_files_limit value change is invalid

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.