All Products
Search
Document Center

ApsaraDB for ClickHouse:ZooKeeper management

Last Updated:Mar 28, 2026

ApsaraDB for ClickHouse lets you manage the ZooKeeper cluster bundled with your ClickHouse cluster. When the ZooKeeper Transaction ID (ZXID) usage is high, schedule a leader switchover to re-elect a ZooKeeper leader and reset the ZXID.

Important

Only perform this operation when ZXID usage is high.

Prerequisites

Before you begin, ensure that:

  • The cluster status is Running

  • The cluster is not undergoing a restart

Potential impacts

During a ZooKeeper leader switchover, all connections between ClickHouse nodes and ZooKeeper are temporarily disconnected. The following table summarizes the impacts by area:

AreaImpactSeverity
QueriesNot affected
Write operations (write suspension disabled)Tables using ReplicatedMergeTree engines experience transient connection dropsMedium
Write operations (write suspension enabled)All write operations fail for the duration of the switchoverHigh
DDL operationsDistributed DDL execution may be blockedMedium
Metadata consistencyHigh-frequency writes during switchover may cause metadata inconsistency; affected tables enter a Read-only stateHigh

Duration:

ModeDuration
Write suspension disabledApproximately 1–2 minutes
Write suspension enabledApproximately 2–10 minutes (no writes allowed)

To avoid metadata inconsistency, reduce write frequency or stop write operations during the switchover.

Schedule a leader switchover

  1. Log on to the ApsaraDB for ClickHouse console.

  2. In the upper-left corner, select the region where your cluster is deployed.

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

  4. On the Cluster Information page, find the ZooKeeper Configuration section under Configuration Information in the lower-left corner, then click Schedule Time.

  5. In the Configure Primary/Secondary Switchover dialog, read the impact information and click OK.

  6. Configure the following settings:

    • Configure Write Suspension:

      OptionBehavior
      Enable Write SuspensionThe cluster blocks all write operations during the switchover. Duration: 2–10 minutes.
      Disable Write SuspensionThe cluster performs the switchover without blocking writes. Duration: 1–2 minutes.
    • Select Mode:

      OptionBehavior
      Scheduled TimeSet a specific time for the switchover to begin.
      Execute ImmediatelyStart the switchover right away.
  7. Click OK.

After the switchover begins, the cluster status changes to Switching Primary/Secondary Node. When the status returns to Running, the switchover is complete.

Modify or cancel a scheduled switchover

Important

You can only modify or cancel a switchover if the cluster is already in Scheduled Time mode.

  1. Log on to the ApsaraDB for ClickHouse console.

  2. In the upper-left corner, select the region where your cluster is deployed.

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

  4. On the Cluster Information page, find the ZooKeeper Configuration section under Configuration Information in the lower-left corner, then click Scheduled Time.

  5. In the Configure Primary/Secondary Switchover dialog, select an action:

    ActionDescription
    ModifyUpdate all configurations for the scheduled switchover.
    CancelCancel the scheduled switchover.