如何控制 ClickHouse 系统日志表的大小

在使用 ClickHouse 时会发现它的系统日志表会不断增大,最终可能会导致磁盘空间不足。

以下这些表属于系统的日志表:metric_log, query_log, query_thread_log, trace_log, part_log, crash_log, text_log, backup_log。

这些表中存储的是各种日志,ClickHouse 默认没有限制这些表的大小。

根据其官方文档的说法:

By default, table growth is unlimited. To control a size of a table, you can use TTL settings for removing outdated log records. Also you can use the partitioning feature of MergeTree-engine tables.

可以通过设置这些表的 TTL 来自动删除过期的数据,从而控制表的大小,限制磁盘空间的使用。

https://clickhouse.com/docs/en/operations/system-tables

comments powered by Disqus