无法在Ubuntu 15中增加Mysql最大连接的max_open_files [英] Can not increase max_open_files for Mysql max-connections in Ubuntu 15

查看:133
本文介绍了无法在Ubuntu 15中增加Mysql最大连接的max_open_files的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行此版本的Mysql

I am running this version of Mysql

Ver 14.14 Distrib 5.6.24, for debian-linux-gnu (x86_64)

在此版本的Ubuntu

On this version of Ubuntu

Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:    15.04
Codename:   vivid

这是我为Mysql设置的配置:

This is the config I set for Mysql:

key_buffer_size     = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
innodb_buffer_pool_size=20G
innodb_log_buffer_size=16M
tmp_table_size = 32M
max_heap_table_size = 32M
open-files-limit=4510
max_connections=500
myisam-recover         = BACKUP
query_cache_type=1
query_cache_limit   = 32M
query_cache_size        = 32M

这些是我在启动MYSQL时不断收到的警告:

These are the warnings I keep getting when starting MYSQL:

2015-06-17 17:28:53 26720 [Warning] Buffered warning: Could not increase number 
of max_open_files to more than 1024 (request: 4510)

2015-06-17 17:28:53 26720 [Warning] Buffered warning: Changed limits: max_connections: 
214 (requested 500)

2015-06-17 17:28:53 26720 [Warning] Buffered warning: Changed limits: table_open_cache: 
400 (requested 2000)

我已经尝试了以下步骤:

I already tried these steps:

1)将其添加到/etc/security/limits.conf

mysql           soft    nofile          65535
mysql           hard    no file          65535

2)将其添加到/etc/pam.d/common-auth/etc/pam.d/commom-session

session required pam_limits.so

3)将此添加到/etc/mysql/mysql.conf.d/mysqld.cnf

open-files-limit=4510 or open_files_limit=4510

这些都不起作用,我仍然无法将mysql的最大连接数提高到500.

None of these have worked and I am still not able to raise the mysql max connections to 500.

在此,我非常感谢您的帮助.

I'd really appreciate some help at this point.

非常感谢.

推荐答案

Ubuntu在版本15.04中已从Upstart迁移到Systemd,并且不再遵守/etc/security/limits.conf中的系统服务限制.这些限制现在仅适用于用户会话.

Ubuntu has moved from Upstart to Systemd in version 15.04 and no longer respects the limits in /etc/security/limits.conf for system services. These limits now apply only to user sessions.

MySQL服务的限制是在Sy​​stemd配置文件中定义的,您应该将其从默认位置复制到/etc/systemd中,然后编辑该副本.

The limits for the MySQL service are defined in the Systemd configuration file, which you should copy from its default location into /etc/systemd and then edit the copy.

sudo cp /lib/systemd/system/mysql.service /etc/systemd/system/
sudo vim /etc/systemd/system/mysql.service # or your editor of choice

在文件底部添加以下几行:

Add the following lines to the bottom of the file:

LimitNOFILE=infinity
LimitMEMLOCK=infinity

您还可以设置数字限制,例如LimitNOFILE=4510.

You could also set a numeric limit, eg LimitNOFILE=4510.

现在使用以下命令重新加载Systemd配置:

Now reload the Systemd configuration with:

sudo systemctl daemon-reload

重新启动MySQL,它现在应遵守max_connections指令.

Restart MySQL and it should now obey the max_connections directive.

在升级到15.04后,我也无法完全停止MySQL.如果这对您造成影响(您会知道,因为执行service mysql stopservice mysql restart会花费300秒的超时时间),则将以下行添加到已修复的同一/etc/systemd/system/mysql.service文件中对我来说:

I also had problems stopping MySQL cleanly after upgrading to 15.04. If this affects you (you'll know because it will take 300 seconds to time out when you do service mysql stop or service mysql restart) then adding the following line to the same /etc/systemd/system/mysql.service file fixed it for me:

ExecStop=/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown

后一个问题似乎已由16.04修复,并且不再需要此行,因此在进行发行版升级之前,您将要停止MySQL并从配置文件中删除ExecStop行.

This latter problem seems to have been fixed by 16.04 and this line is no longer required, so before you do a distribution upgrade you'll want to stop MySQL and remove the ExecStop line from the config file.

这篇关于无法在Ubuntu 15中增加Mysql最大连接的max_open_files的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆