加入收藏 | 设为首页 | 会员中心 | 我要投稿 常州站长网 (https://www.0519zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux – MySQL:max_allowed_pa??cket可能大于1 GB吗?

发布时间:2021-03-15 13:23:14 所属栏目:Linux 来源:网络整理
导读:在数字取证领域,1GB的数据包很常见,我遇到了麻烦. 使用内部python脚本,我们从档案中提取文本,一些文件大到4 GB,其中的文本可以轻松达到1GB.然后我们使用Sphinxsearch使其可搜索. 所以现在我在将这些文本插入数据库时??面临数据包太大的错误. 机器是64核心,

在数字取证领域,1GB的数据包很常见,我遇到了麻烦.

使用内部python脚本,我们从档案中提取文本,一些文件大到4 GB,其中的文本可以轻松达到1GB.然后我们使用Sphinxsearch使其可搜索.

所以现在我在将这些文本插入数据库时??面临数据包太大的错误.

机器是64核心,64 GB的RAM,可以轻松handel Terrabytes.

所以我该怎么做?

另一个问题是,增加max_allow_packet是否也增加了内存使用量,在< 1GB包? 操作系统:Linux 2.6.39
Mysql:5.1和5.5

解决方法

在改变 max_allowed_packet之前,首先让我们来定义它.

根据page 99 of “Understanding MySQL Internals” (ISBN 0-596-00957-7),以下是第1-3段解释它:

MySQL network communication code was
written under the assumption that
queries are always reasonably short,
and therefore can be sent to and
processed by the server in one chunk,
which is called a packet in MySQL
terminology. The server allocates the
memory for a temporary buffer to store
the packet,and it requests enough to
fit it entirely. This architecture
requires a precaution to avoid having
the server run out of memory—a cap
on the size of the packet,which this
option accomplishes.

The code of interest in relation to
this option is found in
sql/net_serv.cc. Take a look at my_net_read(),then follow the call to my_real_read() and pay
particular attention to
net_realloc().

This variable also limits the length
of a result of many string functons.
See sql/field.cc and
sql/intem_strfunc.cc for details.

根据本书的摘录和max_allowed_pa??cket上的MySQL文档,对于max_allowed_pa??cket而言,基本上没有什么可以超越1G.但是,还有一个方面需要探讨BLOB和文本数据调优.

关于InnoDB和BLOB,Another question in Server Fault做了以下断言:innodb_log_file_size和innodb_log_buffer_size组合必须大于你的最大blob对象的十倍,如果你有很多大的对象.如果你不这样做(并且你不应该[1,2]),那么真的没有必要用它来打扰.查看MySQL性能博客,获取有关如何计算的详细报告.

还有另一个需要考虑的方面:选项net_buffer_length(默认为16K)用作MySQL数据包的初始化大小.数据包可以动态扩展到max_allowed_pa??cket.它不可避免地缩回到net_buffer_length指定的大小. net_buffer_length的最大值为1M.您可能希望将此值设置为1M.如果您正在驾驶1G,可能没多大帮助,但也不会有任何伤害.

如果你真的想要一个大于1G的MySQL数据包,我引用的那本书摘录告诉你使用什么源代码来定义MySQL数据包内部.您可以自由尝试提高限额.但是,如果代码假定1G除了设置显式数字之外,源代码可能具有自己的内部限制.

我希望这个信息有帮助!

(编辑:常州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读