暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

clickhouse如何删除大表

数据库干货铺 2022-06-14
4107
点击上方蓝字关注我

clickhouse 在单表或单分区超过50GB时,将无法直接删除

1. 案例

模拟删除单表或单分区超过50GB时,删除报错的情况

1.1 一个表中超过50GB的分区

    -- 删除分区的脚本如下
    ALTER TABLE testdb.test DROP PARTITION (20220606,'12');
    报错信息如下
      Code: 359. DB::Exception: Received from localhost:9000. DB::Exception: Table or Partition in testdb.test was not dropped.
      Reason:
      1. Size (56.20 GB) is greater than max_[table/partition]_size_to_drop (50.00 GB)
      2. File '/data/clickhouse/flags/force_drop_table' intended to force DROP doesn't exist
      How to fix this:
      1. Either increase (or set to zero) max_[table/partition]_size_to_drop in server config
      2. Either create forcing file data/clickhouse/flags/force_drop_table and make sure that ClickHouse has write permission for it.
      Example:
      sudo touch '/data/clickhouse/flags/force_drop_table' && sudo chmod 666 '/data/clickhouse/flags/force_drop_table'.


      1.3 解决方法

      报错信息中已给出解决方法:

      1) 增大单表或单分区的可删除的大小

      2) 通过执行脚本,强制删除

      1.4  我们选择强制删除来解决

      执行如下脚本

        sudo touch '/data/clickhouse/flags/force_drop_table' && sudo chmod 666 '/data/clickhouse/flags/force_drop_table'
        执行完毕以上脚本后即可删除分区
        往期精彩回顾

        1.  MySQL高可用之MHA集群部署

        2.  mysql8.0新增用户及加密规则修改的那些事

        3.  比hive快10倍的大数据查询利器-- presto

        4.  监控利器出鞘:Prometheus+Grafana监控MySQL、Redis数据库

        5.  PostgreSQL主从复制--物理复制

        6.  MySQL传统点位复制在线转为GTID模式复制

        7.  MySQL敏感数据加密及解密

        8.  MySQL数据备份及还原(一)

        9.  MySQL数据备份及还原(二)

        扫码关注     


        文章转载自数据库干货铺,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

        评论