MySQL 5.7中的max_connections [英] The max_connections in MySQL 5.7

查看:896
本文介绍了MySQL 5.7中的max_connections的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,在通过编辑my.cnf将它设置为1000后,MySQL中的max_connction值为214,如下所示:

I met a problem, the value of max_connction in MySQL is 214 after I set it 1000 via edit the my.cnf, just like below:

hadoop@node1:~$ mysql -V
mysql  Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using  EditLine wrapper

MySQL版本:5.7

MySQL version: 5.7

操作系统版本:ubuntu 16.04LTS

OS version : ubuntu 16.04LTS

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+
1 row in set (0.00 sec)

我们可以看到,max_connections的变量值为151.然后,我编辑MySQL的配置文件.

As we can see, the variable value of max_connections is 151. Then , I edit the configuration file of MySQL.

yang2@node1:~$ sudo vi /etc/mysql/my.cnf
[mysqld]

character-set-server=utf8
collation-server=utf8_general_ci
max_connections=1000

保存配置后重新启动MySQL服务.

Restart MySQL service after save the configraion.

yang2@node1:~$ service mysql restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'mysql.service'.
Multiple identities can be used for authentication:
 1.  yangqiang,,, (yang2)
 2.  ,,, (hadoop)
Choose identity to authenticate as (1-2): 1
Password: 
==== AUTHENTICATION COMPLETE ===
yang2@node1:~$ 

现在,我们估计max_connection是1000,真的吗?

Now, we guess the max_connection is 1000, really?

mysql> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 214   |
+-----------------+-------+
1 row in set (0.00 sec)

现在是214.我不太了解这个结果,谁能帮助我?谢谢!

It is 214. I do not really understand this result, who can help me? thx!

推荐答案

作为

增加该值会增加文件描述符的数量, mysqld要求.如果所需的描述符数量未达到 如果可用,服务器将减少max_connections的值.

Increasing this value increases the number of file descriptors that mysqld requires. If the required number of descriptors are not available, the server reduces the value of max_connections.

这意味着您的MySQL服务器可能没有足够的资源来维护所需数量的描述符.

This means that probably your MySQL server does not have enough resources to maintain the required number of descriptors.

MySQL如何打开和关闭表的MySQL文档明确指出:

table_open_cache和max_connections系统变量会影响 服务器保持打开状态的最大文件数.如果增加一个或 这两个值,您可能会遇到由您施加的限制 操作系统上每个进程打开文件描述符的数量. 许多操作系统允许您增加打开文件的限制, 尽管方法因系统而异.咨询你的 操作系统文档,以确定是否有可能 增加限制以及操作方法.

The table_open_cache and max_connections system variables affect the maximum number of files the server keeps open. If you increase one or both of these values, you may run up against a limit imposed by your operating system on the per-process number of open file descriptors. Many operating systems permit you to increase the open-files limit, although the method varies widely from system to system. Consult your operating system documentation to determine whether it is possible to increase the limit and how to do so.

这篇关于MySQL 5.7中的max_connections的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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