ApsaraDB for ClickHouse lets you manage the ZooKeeper cluster bundled with your ClickHouse cluster. When ZooKeeper ZXID usage is high, you can schedule a leader switchover. This operation triggers a leader re-election in ZooKeeper to reset the ZXID.
Prerequisites
-
The cluster status is Running.
-
A cluster restart has not been performed.
Cluster impact
-
Queries: Not affected.
-
Write operations:
-
Write operations to tables that use a ReplicatedMergeTree table engine may be transiently interrupted.
-
If write suspension is enabled during the leader switchover, the instance enters a state of write suspension after the switchover begins. All write operations to the instance will fail.
-
-
DDL operations: The switchover may block distributed DDL execution.
-
Duration:
-
Without write suspension: Approximately 1 to 2 minutes.
-
With write suspension: Approximately 2 to 10 minutes (write operations are blocked for the entire duration).
-
-
Potential metadata inconsistency.
A ZooKeeper leader switchover disconnects all ClickHouse nodes from ZooKeeper. If high-frequency write operations occur during this process, this can cause metadata inconsistency and force some tables in the cluster into a
Read-onlystate.To prevent metadata inconsistency, reduce the write frequency or stop write operations during the switchover period.
Leader switchover
-
Log on to the ApsaraDB for ClickHouse console.
-
In the upper-left corner of the page, select the region of your target cluster.
-
On the Clusters page, select Clusters of Community-compatible Edition, and then click the ID of the target cluster.
-
On the Cluster Information page, in the Zookeeper Configurations section under Configuration Information, click Scheduled Time.
-
In the Configure Primary/Secondary Switchover dialog box, review the impacts of this operation, and then click OK.
-
In the Configure Primary/Secondary Switchover dialog box, configure Configure Write Suspension and Select Mode.
-
Configure Write Suspension:
-
Enable Write Suspension: The instance blocks write operations during the switchover. All write operations to the instance will fail during this period. The process takes 2 to 10 minutes.
-
Disable Write Suspension: The instance performs the leader switchover directly without blocking write operations.
-
-
Select Mode:
-
Scheduled Time: In the Scheduled Time field, set a time for the leader switchover. The switchover starts at the scheduled time.
-
Execute Immediately: The cluster starts the leader switchover immediately.
-
-
-
Click OK.
NoteAfter the leader switchover starts, the cluster status changes to Switching Primary/Secondary Node. The operation is complete when the status returns to Running.
Modify or cancel the schedule
You can modify or cancel the schedule only for clusters that use the Schedule Switchover mode.
-
Log on to the ApsaraDB for ClickHouse console.
-
In the upper-left corner of the page, select the region of your target cluster.
-
On the Clusters page, select Clusters of Community-compatible Edition, and then click the ID of the target cluster.
-
On the Cluster Information page, in the Zookeeper Configurations section under Configuration Information, click Scheduled Time.
-
In the Configure Primary/Secondary Switchover dialog box, select Modify or Cancel.
-
Modify: You can modify all leader switchover settings.
-
Cancel: Cancels the scheduled leader switchover.
-