查看Mysql日志/var/log/mysqld.log,有如下报错:
2019-05-28T15:08:16.325376Z 0 [ERROR] [MY-010283] [Server] Error in accept: Too many open files
Mysql版本:
# mysql -V
mysql Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)
CentOS Linux 7 (Core)
解决方法:
查看当前Mysql数据库设置的open_files_limit值:
mysql> show variables like '%open%';
查看当前Mysql运行状态下的Open_files值:
mysql> show status like '%opene%';
1. Change system open file limit on the fly(dynamically). 先修改服务器,修改open files限制为65535.
# ulimit -n 65535
# ulimit -Hn
65535
# ulimit -Sn
65535
# ulimit -n
65535
# ulimit -a
2. Change Mysql open file limit
vi /usr/lib/systemd/system/mysqld.service
LimitNOFILE=65535
LimitNPROC=65535
vi /usr/lib/systemd/system/mysqld.service
# Sets open_files_limit
LimitNOFILE = 65535
vi /etc/security/limits.conf
mysql hard nofile 65535
mysql soft nofile 65535
# vi /etc/systemd/system/multi-user.target.wants/mysqld.service
# Sets open_files_limit
LimitNOFILE = 65535
4. Reload and Restart Mysqld to take effect.
systemctl daemon-reload && systemctl restart mysqld
重启后确认设置生效
mysql> show variables like '%open%';