【问题标题】:Can I delete the detached folder on clickhouse data我可以删除clickhouse数据上的分离文件夹吗
【发布时间】:2020-10-16 03:57:16
【问题描述】:

分离出来的ignored文件夹很多,占用空间太多,可以删除吗?

[root@cl1-data4 billing_test]# du -h --max-depth=1 ./tb_pay_order_log_local/
40G     ./tb_pay_order_log_local/detached

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    如果您确定这些数据不会被更多使用,可以手动从文件系统中删除。

    我更愿意使用专门的操作DROP DETACHED PARTITION 删除 ClickHouse 工件:

    # get list of detached partitions
    SELECT database, table, partition_id
    FROM system.detached_parts
    
    # drop them one by one
    ALTER TABLE {database}.{table} DROP DETACHED PARTITION {partition_id}
    

    或者自动化它(想法是借用CH github: Attach all detached partitions #8183):

    # warning [be careful]: this script remove ALL detached parts of ALL tables
    # to affect only one table need to add "WHERE table = 'tb_pay_order_log_local'"
    
    clickhouse-client --format=TSVRaw  \
        -q"select 'ALTER TABLE ' || database || '.' || table || ' DROP DETACHED PARTITION \'' || partition_id || '\';\n' from system.detached_parts group by database, table, partition_id order by database, table, partition_id;"  \
       | clickhouse-client -mn --allow_drop_detached 1
    

    【讨论】:

      【解决方案2】:

      您可以删除_ignored。

      谷歌翻译:

      不活动的部分不会立即删除,因为在写入新块时,不会调用fsync,即在一段时间内,新部分仅位于服务器的 RAM(OS 缓存)中。因此,如果服务器(HW)自发重启,新合并的部分可能会丢失或损坏。那么ClickHouse在启动过程中就是在检查parts的完整性,可以检测到问题,把不活跃的parts返回到active list,之后再重新合并。然后将损坏的部分重命名(添加前缀 broken)并移至分离的文件夹。如果完整性检查在合并的块中检测到没有问题,则将原始非活动块重命名(添加前缀 ignored)并移至分离的文件夹。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-11-14
        • 1970-01-01
        • 2013-09-26
        • 1970-01-01
        • 2014-02-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多