简体   繁体   English

存储日志的最佳数据类型

[英]Best datatype to store logs

I have a MySQL table named requests . 我有一个名为requests的MySQL表。 It's growing so fast. 它发展得如此之快。 Currently, it has 3 million rows. 目前,它有300万行。 Also, the current table engine is "InnoDB". 另外,当前的表引擎是“ InnoDB”。

Few days ago, I got this error: 几天前,我收到此错误:

ERROR 1114 (HY000): The table is full 错误1114(HY000):表已满

I've resolved the problem (temporary I guess) by adding this to MySQL configuration: 通过将其添加到MySQL配置中,我已经解决了这个问题(我想是暂时的):

innodb_data_file_path = ibdata1:10M:autoextend

But still sometimes my serves goes to down and I have to restart it to make it available. 但是有时候我的发球会掉下来,我必须重新启动它才能使用。 Recently, I've made that table empty and I got rid of being down. 最近,我将桌子空了,摆脱了掉下来的麻烦。

But it will be full again soon. 但是很快就会充满。 Any idea how can I fix that issue? 知道如何解决该问题吗? Should I use another engine for that table? 我应该为该表使用其他引擎吗? Should I use compressed type-row for it? 我应该使用压缩的类型行吗? or what? 要不然是啥?

Noted that, sometimes I need to select from that table and it has one index on a column (in addition to pk) 注意,有时我需要从该表中进行选择,并且该表在列上有一个索引(除了pk)

You are limited by disk space. 您受到磁盘空间的限制。 You must keep an eye on that and take action before you get to "table full". 必须密切注意并采取行动,然后才能达到“满桌”状态。

If you store the data in a MyISAM table, you can go twice as long before getting "table full". 如果将数据存储在MyISAM表中,则可以花两倍的时间才能获取“表已满”。 If you simply write to a disk file (no database, no queries; etc), you can squeeze a little more in before "disk full". 如果您只是简单地写入磁盘文件(无数据库,无查询等),则可以在“磁盘已满”之前再进行一些压缩。

Do you need to "purge" old data? 您是否需要“清除”旧数据? That way you could continue to receive new data without ever hitting "table full". 这样,您就可以继续接收新数据,而无需触及“表已满”。 The best way to do that is via InnoDB and PARTITION BY RANGE(TO_DAYS(...)) . 最好的方法是通过InnoDB和PARTITION BY RANGE(TO_DAYS(...)) If you purge anything over a month old, use daily partitions. 如果清除一个月以上的任何东西,请使用每日分区。 For, say, 90 days, use weekly partitions. 例如,对于90天,请使用每周分区。 More discussion: http://mysql.rjweb.org/doc.php/partitionmaint 更多讨论: http : //mysql.rjweb.org/doc.php/partitionmaint

What will you do with the data? 您将如何处理数据? Analyze it? 分析一下吗? Search it? 搜索一下? What SQL queries do you envision? 您打算进行哪些SQL查询? Answer those; 回答那些; there could be other tips. 可能还有其他提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM