微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

在数字取证领域,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_sizeinnodb_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除了设置显式数字之外,源代码可能具有自己的内部限制.

我希望这个信息有帮助!

原文地址:https://www.jb51.cc/linux/397821.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐