gpt4 book ai didi

mysql - 无法在 Ubuntu 15 中为 Mysql max-connections 增加 max_open_files

转载 作者:IT老高 更新时间:2023-10-28 23:44:03 25 4
gpt4 key购买 nike

我正在运行这个版本的 Mysql

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

在这个版本的 Ubuntu 上

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

这是我为 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 时不断收到的警告:

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)

我已经尝试了这些步骤:

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。

在这一点上,我非常感谢一些帮助。

非常感谢。

最佳答案

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

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

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

将以下行添加到文件底部:

LimitNOFILE=infinity
LimitMEMLOCK=infinity

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

现在重新加载 Systemd 配置:

sudo systemctl daemon-reload

重新启动 MySQL,它现在应该遵循 max_connections 指令。

升级到 15.04 后,我也遇到了完全停止 MySQL 的问题。如果这会影响到您(您会知道,因为执行 service mysql stopservice mysql restart 将需要 300 秒才能超时)然后将以下行添加到相同的/etc/systemd/system/mysql.service 文件为我修复了它:

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

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

关于mysql - 无法在 Ubuntu 15 中为 Mysql max-connections 增加 max_open_files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30901041/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com