Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

스토리지 장애 후 레플리카를 복원하는 방법

정상 레플리카에서 access 구성 복사

로컬 사용자가 포함된 access 폴더의 내용을 정상 레플리카에서 복사합니다:

/var/lib/clickhouse/access

정상 레플리카에서 메타데이터 폴더 백업

  1. ClickHouse 데이터 디렉터리로 이동합니다:
cd /var/lib/clickhouse
  1. 메타데이터 폴더를 백업합니다(심볼릭 링크 포함). 메타데이터 디렉터리에는 데이터베이스와 테이블의 DDL이 들어 있습니다. 데이터베이스 디렉터리에는 모든 테이블 DDL이 들어 있는 /var/lib/clickhouse/store/..를 가리키는 심볼릭 링크가 있습니다.
{ find metadata -type f; find metadata -type l; find metadata -type l | xargs readlink -f; } | tar -cPf backup.tar --files-from=-

장애가 발생한 레플리카에서 메타데이터 복원

  1. 생성된 backup.tar 파일을 장애가 발생한 레플리카로 복사합니다.
  2. 이 파일을 ClickHouse 데이터 디렉터리에 압축 해제합니다:
cd /var/lib/clickhouse/
tar -xvPf backup.tar

강제 복원 플래그 생성

다른 레플리카에서 자동으로 데이터를 동기화하도록 다음 플래그를 생성합니다:

sudo -u clickhouse touch /var/lib/clickhouse/flags/force_restore_data

장애가 발생한 레플리카 재시작

  1. 장애가 발생한 노드에서 ClickHouse 서버를 재시작합니다.
  2. 서버 로그를 확인합니다. 정상 레플리카에서 파트가 다운로드되는 것을 확인할 수 있습니다:
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
Navigation