Skip to content

Commit fc40ddd

Browse files
Clarify SYSTEM RESTORE REPLICA command usage
Updated instructions for restoring replication metadata in ZooKeeper by specifying the table name. Added a query to automate restoration for all replicated tables.
1 parent 97d5152 commit fc40ddd

File tree

1 file changed

+17
-4
lines changed
  • content/en/altinity-kb-setup-and-maintenance/altinity-kb-data-migration

1 file changed

+17
-4
lines changed

content/en/altinity-kb-setup-and-maintenance/altinity-kb-data-migration/rsync.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,29 @@ When migrating a large, live ClickHouse cluster (multi-terabyte scale) to a new
3838
- Each subsequent run will copy only changes and reduce the final sync time.
3939
5. **Restore replication metadata**
4040
- Start the new ClickHouse node(s).
41-
- Run `SYSTEM RESTORE REPLICA` to rebuild replication metadata in ZooKeeper.
41+
- Run `SYSTEM RESTORE REPLICA table_name` to rebuild replication metadata in ZooKeeper.
4242
6. **Test the application**
4343
- Point your test environment to the new cluster.
4444
- Validate queries, schema consistency, and application behavior.
4545
7. **Final sync and switchover**
4646
- Stop ClickHouse on the old cluster.
4747
- Immediately run a final incremental `rsync` to catch last-minute changes.
4848
- Reinitialize ZooKeeper/Keeper database (stop/clear snapshots/start).
49-
- Run `SYSTEM RESTORE REPLICA` to rebuild replication metadata in ZooKeeper again.
49+
- Run `SYSTEM RESTORE REPLICA table_name` to rebuild replication metadata in ZooKeeper again.
5050
- Start ClickHouse on the new cluster and switch production traffic.
5151
- add more replicas as needed
5252

5353

5454
NOTES:
5555

56-
1. If you are using a mount point that differs from /var/lib/clickhouse/data, adjust the rsync command accordingly to point to the correct location. For example, suppose you reconfigure the storage path as follows in /etc/clickhouse-server/config.d/config.xml.
56+
1. You can build a script to run restore replica commands over all replicated tables by query:
57+
```
58+
select 'SYSTEM RESTORE REPLICA ' || database || '.' || table || ';'
59+
from system.tables
60+
where engine ilike 'Replicated%'
61+
```
62+
63+
2. If you are using a mount point that differs from /var/lib/clickhouse/data, adjust the rsync command accordingly to point to the correct location. For example, suppose you reconfigure the storage path as follows in /etc/clickhouse-server/config.d/config.xml.
5764
```
5865
<clickhouse>
5966
<!-- Path to data directory, with trailing slash. -->
@@ -63,4 +70,10 @@ NOTES:
6370
```
6471
You'll need to use `/data1/clickhouse` instead of `/var/lib/clickhouse` in the rsync paths.
6572
66-
2. ClickHouse docker container image does not have rsync installed. Add it using apt-get or run sidecar in k8s.
73+
3. ClickHouse Docker container image does not have rsync installed. Add it using apt-get or run sidecar in k8s or run a service pod with volumes attached.
74+
For clickhouse-operator instances, you can to stop all pods by CHI definition.
75+
```
76+
spec:
77+
stop: "true"
78+
```
79+

0 commit comments

Comments
 (0)