锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

clickhouse如何删除大表

时间:2022-08-27 08:00:00 低浓度甲烷传感器gjc4

点击上面的蓝字关注我

216e493ddc5f4a25cb21d80188ce09da.png

clickhouse单表或单分区超过50个GB不能直接删除

1. 案例

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

1.1 表中超过50GB的分区

--删除分区的脚本如下 ALTERTABLEtestdb.testDROPPARTITION(20220606,‘12’)
错误信息如下
Code:359.DB::Exception:Receivedfromlocalhost:9000.DB::Exception:TableorPartitionintestdb.testwasnotdropped. 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 我们选择强制删除来解决

执行以下脚本

sudotouch'/data/clickhouse/flags/force_drop_table'&&sudochmod666'/data/clickhouse/flags/force_drop_table'

执行上述脚本后,可以删除分区

过去的精彩回顾

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

2.mysql8.新用户和修改加密规则的事情

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

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

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

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

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

8.MySQL数据备份和还原(1)

9.MySQL数据备份和还原(2)

扫码关注

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章