参考链接: https://segmentfault.com/a/1190000042179953 https://www.jianshu.com/p/06b79e8db75c
服务器意外断电后,Clichouse一直重试失败,完整错误:
2022.09.25 02:24:45.391647 [ 144 ] {} <Error> iioory_status (2593be6b-d88e-4766-a593-be6bd88e2766): Detaching broken part /var/lib/clickhouse/store/259/2593be6b-d88e-4766-a593-be6bd88e2766/202209_1_92218_53720 (size: 0.00 B). If it happened after update, it is likely because of backward incompability. You need to resolve this manually
一、处理方法
1.1修改max_suspicious_broken_parts启动服务
先参考链接一,修改max_suspicious_broken_parts成功启动Clickhouse。
配置参数当中包含一个参数max_suspicious_broken_parts,默认值是10,可选值范围是任意正整数,如果单个分区中的损坏部分数量超过max_suspicious_broken_parts 配置的值,则拒绝自动修复或者拒绝删除损坏部分的数据,并且服务启动时候直接报错退出
目前需要尽量避免该错误以免服务启动失败,推荐把该参数配置为1000或者更大的值。
新建文件max_suspicious_broken_parts.xml写入如下内容
<?xml version="1.0"?>
<yandex>
<merge_tree>
<max_suspicious_broken_parts>1000</max_suspicious_broken_parts>
</merge_tree>
</yandex>
clickhouse的配置文件推荐放置在/etc/clickhouse-server/config.d/文件夹下生效。
重启clickhouse,成功启动clickhouse数据库。
1.2 修复数据库
sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data