gpt4 book ai didi

Mysql在高峰时段开始断开连接

转载 作者:行者123 更新时间:2023-11-29 12:04:28 25 4
gpt4 key购买 nike

我们的数据库在高峰时段开始断开连接。大约有 3% 连接丢失,mysql 返回消息 "mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '10.88.***' (99)"。我调整了几个mysql和内核参数,但没有帮助:-/etc/sysctl.conf:

net.ipv4.tcp_max_tw_buckets = 524288 net.core.somaxconn = 2048 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog=30000 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_synack_retries = 2

-/etc/my.cnf:

open_files_limit = 65536 max_connections=3600
connect_timeout=60
wait_timeout=2400
back_log=4096

-/etc/security/limits.conf

mysql soft nofile 65536 mysql hard nofile 65536 mysql soft nproc 65536 mysql hard nproc 65536

我们的数据库在一台数据库机器上每秒处理 >40000 次查询和 > 8000 个连接,没有分片和连接池。我缺少什么?有谁知道什么可能导致这一瓶颈?谢谢。

以下是 my.cnf 中的内容:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

skip_name_resolve = off
open_files_limit = 65536

max_allowed_packet = 1073741824
expire_logs_days = 2

binlog_format = row
innodb_file_per_table = 1
innodb_flush_method=O_DIRECT

innodb_buffer_pool_instances = 16
innodb_buffer_pool_size = 43G
innodb_thread_concurrency = 0

log-bin=mysql-bin
server-id=1
innodb_flush_log_at_trx_commit=1
slave-skip-errors = 1062,1032

max_connections=3600
connect_timeout=60
wait_timeout=2400

back_log=4096

thread_cache_size=48

symbolic-links=0

user=mysql

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
!includedir /etc/my.cnf.d

最佳答案

所以..尝试将 max_connections 增加到 > 8000 ?

在 my.cnf 中

max_connections=9000

关于Mysql在高峰时段开始断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31779770/

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