我的 mysql.general_log 表变得太大了吗?
我最近刚刚升级到 MySQL 5.1.6,以便利用将常规日志保存到表的功能 ->即 mysql.general_log。一旦我这样做了,我立即惊讶地发现有多少查询实际上正在访问我们的系统。从第一个小时开始,我的通用日志表中有大约 40,000 行。我还没有发现 MySQL 文档上写有关于是否有一般日志表大小限制的内容。
让这个通用日志以这样的速度增长有问题吗?
如果出现尺寸问题,如何处理?
如果存在尺寸问题,是否有一些公认的做法来处理尺寸问题?
我是否应该经常创建一个事件来清除表并将数据保存到文件中?
非常感谢您的帮助!
I just recently upgraded to MySQL 5.1.6 in order to take advantage of the ability to save the general log to a table -> i.e. mysql.general_log. Once i did this I was immediately surprised how many queries are actually hitting our system. I have about 40,000 rows in this general log table from the first hour. I haven't found it written on the MySQL docs about if there is a general log table size limit.
Is there a problem to letting this general log grow at this rate?
If there is a size problem, how to deal with it?
Are there some accepted practices how to deal with a size problem if there is one?
Should I make an event to purge the table and save the data to a file every so often?
Thanks a lot for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我对我的日志文件做了类似的事情。我只对保留最后 24 小时感兴趣,但您可以调整事件以创建存档表等。它不会记录事件运行所需的几秒钟,但我不介意。
I do something like this for my log file. I'm only interested in keeping the last 24 hours, but you could tweak the event to create archive tables, etc. It won't log for the few seconds it takes the event to run, but I don't mind.
General_log 表默认使用 CSV 引擎,它实际上只是驱动器上的完整 CSV 文件,但可以通过 SQL 访问。这意味着它的大小限制是文件系统上文件的大小限制。
The general_log table by default uses the CSV engine, which is literally just a full-blown CSV file on your drive, but can be accessed via SQL. This means its size limit is the size limit of files on your file system.
您应该使用一些实用程序,例如
mysql-log-rotate
http://dev.mysql.com/doc/refman/5.0/en/log-file-maintenance.html 用于轮换日志文件。You should use some utility like
mysql-log-rotate
http://dev.mysql.com/doc/refman/5.0/en/log-file-maintenance.html for rotating log file.不确定这是否是最佳实践,但这是我的解决方案:
Not sure if this is best practice but this was my solution: