从健康副本复制访问配置
从健康副本复制 access 文件夹的内容,该文件夹包含本地用户:
/var/lib/clickhouse/access从健康副本备份 metadata 文件夹
- 进入 ClickHouse 数据目录:
cd /var/lib/clickhouse- 备份 metadata 文件夹 (包括符号链接) :metadata 目录包含数据库和表的 DDLs。
数据库目录中包含指向
/var/lib/clickhouse/store/..的符号链接,其中保存了所有表的 DDLs。
{ find metadata -type f; find metadata -type l; find metadata -type l | xargs readlink -f; } | tar -cPf backup.tar --files-from=-在故障副本上恢复 metadata
- 将生成的
backup.tar文件复制到故障副本。 - 将其解压到 ClickHouse 数据目录:
cd /var/lib/clickhouse/
tar -xvPf backup.tar创建强制恢复标志
要触发从其他副本自动同步数据,请创建以下标志文件:
sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data重启故障副本
- 在故障节点上重启 ClickHouse server。
- 检查服务器日志,您应会看到系统正在从健康副本下载 parts:
2025.11.02 00:00:04.047097 [ 682 ] {} <Debug> analytics.events_local (...) (Fetcher): Downloading files 23
2025.11.02 00:00:04.055542 [ 682 ] {} <Debug> analytics.events_local (...) (Fetcher): Download of part 202511_0_0_0 onto disk disk2 finished.
2025.11.02 00:00:04.101888 [ 687 ] {} <Debug> warehouse.customers_local (...) (Fetcher): Downloading part 2025_0_0_1 onto disk default.
2025.11.02 00:00:04.102005 [ 687 ] {} <Debug> warehouse.customers_local (...) (Fetcher): Downloading files 11
2025.11.02 00:00:04.102210 [ 690 ] {} <Debug> warehouse.customers_local (...) (Fetcher): Downloading part 2022_0_0_1 onto disk disk1.
2025.11.02 00:00:04.102247 [ 688 ] {} <Debug> warehouse.customers_local (...) (Fetcher): Downloading part 2021_0_0_1 onto disk disk2.
2025.11.02 00:00:04.102331 [ 690 ] {} <Debug> warehouse.customers_local (...) (Fetcher): Downloading files 11