All Products
Search
Document Center

ApsaraDB for ClickHouse:ZooKeeper management

Last Updated:Nov 24, 2025

ApsaraDB for ClickHouse supports management of the ZooKeeper cluster that comes with your ClickHouse cluster. Currently, you can schedule a leader switching operation for ZooKeeper when the ZXID usage is high. This operation triggers ZooKeeper to re-elect a leader to reset the ZXID.

Prerequisites

  • The cluster status is Running.

  • The cluster is not undergoing a cluster restart.

Impact on clusters

  • Queries: Not affected.

  • Write operations:

    • Write operations to tables with ReplicatedMergeTree series engines will experience transient connections.

    • If write suspension is configured during the leader switching, the instance will enter a write suspension state after the leader switching begins. All write operations to the instance will fail.

  • DDL operations: Distributed DDL execution might be blocked.

  • Duration of impact:

    • Without write suspension configuration: Approximately 1 to 2 minutes.

    • With write suspension configuration: Approximately 2 to 10 minutes (no write operations are allowed during this period).

  • Metadata inconsistency might occur.

    During the ZooKeeper leader switching operation, all connections between ClickHouse nodes and ZooKeeper will be disconnected. If high-frequency write operations are executed during this process, metadata inconsistency might occur, and some tables in the cluster will enter a Read-only state.

    You are recommended to reduce the write frequency or stop write operations during the leader switching period to effectively avoid metadata inconsistency issues.

Leader switching operation

  1. Log on to the ApsaraDB for ClickHouse console.

  2. In the upper-left corner, select the region where the cluster that you want to manage is deployed.

  3. On the Clusters page, select Clusters of Community-compatible Edition, and click the ID of the target cluster.

  4. On the Cluster Information page, click Schedule Time in the ZooKeeper Configuration section of Configuration Information at the lower-left corner of the page.

  5. In the Configure Primary/Secondary Switchover dialog box, carefully read the impact of this operation, and click OK.

  6. In the Configure Primary/Secondary Switchover configuration dialog box, configure Configure Write Suspension and Select Mode.

    • Configure Write Suspension:

      • Enable Write Suspension: The instance will enter a state that prohibits write operations during the leader switching period. All write operations to the instance will fail during this process. The entire process will last at least 2 minutes and at most 10 minutes.

      • Disable Write Suspension: During the leader switching period, the instance will directly perform the leader switching operation without prohibiting write operations to the instance.

    • Select Mode:

      • Scheduled Time: Set the time for cluster leader switching in Scheduled Time. The cluster will start the leader switching at the scheduled time.

      • Execute Immediately: The cluster will immediately perform the leader switching.

  7. Click OK.

    Note

    After the leader switching begins, the cluster status will change to Switching Primary/Secondary Node. When the status changes to Running, the leader switching operation is complete.

Modify or cancel scheduled operations

Important

You can modify or cancel a scheduled operation only if the cluster has already been set to the scheduled leader switching mode during the leader switching operation.

  1. Log on to the ApsaraDB for ClickHouse console.

  2. In the upper-left corner, select the region where the cluster that you want to manage is deployed.

  3. On the Clusters page, select Clusters of Community-compatible Edition, and click the ID of the target cluster.

  4. On the Cluster Information page, click Scheduled Time in the ZooKeeper Configuration section of Configuration Information at the lower-left corner of the page.

  5. In the Configure Primary/Secondary Switchover dialog box, select Modify or Cancel.

    • Modify: All configurations for the cluster leader switching operation can be modified.

    • Cancel: Cancel the scheduled leader switching operation for the cluster.