提出出现在 CentOS 7 ulimit 配置没有问题的情况下mysql日志提示 Warning
# ulimit -Sa | grep "open files" open files (-n) 40960
[root@netkiller ~]# cat /proc/`pidof mysqld`/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size 0 unlimited bytes Max resident set unlimited unlimited bytes Max processes 63494 63494 processes Max open files 5000 5000 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 63494 63494 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us
[root@netkiller ~]# egrep '^(Limit|Max open files)' /proc/`pidof mysqld`/limits Limit Soft Limit Hard Limit Units Max open files 5000 5000 files
问题的出现出现原因是systemctl启动脚本覆盖了ulimit配置
# cat /usr/lib/systemd/system/mysqld.service | grep -A2 open_files_limit # Sets open_files_limit LimitNOFILE = 5000
解决方法,直接修改上面的数值,不建议修改mysqld.service,这样会影响你下次升级。请采用下面的方案完美解决:
mkdir /usr/lib/systemd/system/mysqld.service.d cat >> /usr/lib/systemd/system/mysqld.service.d/override.conf <<EOF [Service] LimitNOFILE=40960 EOF
systemctl daemon-reload systemctl restart mysqld
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。