经常中止与数据库(MariaDB)的连接

问题描述 投票:0回答:1

我有一台运行 MySQL 服务器的 Windows 服务器。 MySQL服务器上有两个数据库用于不同的应用。

每天约有 25 个用户访问数据库服务器。

数据库服务器不在用户的本地网络中(有时甚至不在网络中)。

不幸的是,尽管互联网连接稳定,但我们经常遇到用户无法连接到服务器的问题。只有经过多次尝试后,用户才能成功连接。

当我查看数据库服务器上的日志文件时,我看到很多这样的条目:

1。 2024-03-19 14:08:42 2378 [警告] 已中止与数据库的连接 2378:'CMS_DB' 用户:'JOHN' 主机:'bba-83-130-102-145.alshamil.net.ae' (得到了读取通信数据包时出错)

2。 2024-03-19 13:44:45 1803 [警告] 中止与数据库的连接 1803:'CMS_DB' 用户:'REMA' 主机:'188.137.160.92' (读取通信数据包超时)

3. 2024-03-19 11:51:08 1526 [警告] 中止与数据库的连接 1526:'未连接' 用户:'未经身份验证' 主机:'92.216.164.102' (读取数据包通信时出错)

4。 2024-03-19 11:51:08 1526 [警告] 中止连接 1526 到 db: 'unconnected' user: 'unauthenticated' host: '92.216.164.102' (此连接在没有身份验证的情况下正常关闭)

5。 2024-03-19 11:55:26 1545 [警告] IP 地址“94.202.229.78”无法解析:没有已知的主机。

我的 my.ini 文件如下所示:

[mysqld]
datadir = C:/Program Files/MariaDB 10.5/data
port = 3306
max_allowed_packet=1024M
net_read_timeout=3600
net_write_timeout=3600

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections = 600

wait_timeout = 3600
interactive_timeout = 3600

# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server = utf8

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=50M

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=256M

slow_query_log = ON
slow_query_log_file = C:/Program Files/MariaDB 10.5/data/slow_query_log.log
general_log = ON
general_log_file = C:/Program Files/MariaDB 10.5/data/general_log.log
log_error = C:/Program Files/MariaDB 10.5/data/error_log.log

innodb_page_size = 65536
innodb_buffer_pool_size = 4085M
innodb_log_buffer_size = 32M
innodb_log_file_size = 2047M


[client]
port = 3306
plugin-dir = C:/Program Files/MariaDB 10.5/lib/plugin

我在 hibernate.cfg.xml 中的 c3p0 设置如下所示:

<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">7</property>
<property name="hibernate.c3p0.timeout">120</property>
<property name="hibernate.c3p0.max_statements">20</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">20</property>

我很难看清所有设置。

我希望用户能够轻松连接到数据库服务器,而不是每次都烦我:D

可能是什么问题?我的设置匹配吗?有知道这方面知识的人可以帮帮我吗?

我非常感谢任何有用的答案,因为我已经为此苦苦挣扎了近 5 周,但毫无结果。预先感谢

如果我应该发布任何其他设置(例如服务器变量),请告诉我。

database-connection c3p0 mariadb-10.5
1个回答
0
投票

针对 my.cnf [mysqld] 部分考虑的建议。

扎基,

一般日志通常不开启。

直到实际需要并会使用为止,

general_log=关闭

当需要从 MySQL 命令提示符时,

设置全局general_log=ON

然后,当您完成足够的日志记录时,通常不到一分钟 - 除非您有一个非常长的执行过程,

设置全局general_log=OFF

避免您的存储空间充满您永远不会查看的信息。 相信我,处理一个完整的存储设备并不有趣。

你有真正充分的理由设置 innodb_page_size 任何东西吗 除了默认的 16384 之外?

考虑编辑 my.cnf 以从 64K 恢复到默认值 这对他们尝试过任何事情的少数情况有所帮助 除了16384之外,还被莫名其妙的事件所困扰。

在发布上述评论中要求的附加信息后,将提供附加建议。

© www.soinside.com 2019 - 2024. All rights reserved.