MySQL 5.7 中的 max_connections

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

问题描述

我遇到一个问题,我通过编辑my.cnf将max_connction设置为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!

推荐答案

作为 MySQL 文档在 max_connections 设置说:

As MySQL documentation on max_connections setting says:

增加这个值会增加文件描述符的数量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 如何打开和关闭表 明确表示:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)