The number of shards determines the horizontal scaling capacity of an AnalyticDB for MySQL cluster. If your cluster encounters write performance degradation, query bottlenecks, or resource scaling limits, you can change the shard count to address these issues.
This is a one-time operation. Evaluate the target shard count carefully before proceeding, as it cannot be changed again after completion.
Prerequisites
Before you begin, make sure that:
-
A Data Warehouse Edition cluster exists and is in the Running state
-
The cluster runs minor version 3.2.3.0 or later. To check and update the minor version, go to the Desired Shards section on the Update Time page in the console
-
The cluster specification is not S8 or S16 — these specifications do not support shard changes
-
The shard count has not been changed before on this cluster
Limitations
Shard changes are not supported if any of the following conditions are true:
-
No databases or tables other than the default database exist in the cluster
-
A table with the XUANWU_V2 table engine exists
-
An incrementally updated materialized view exists
Usage notes
Prohibited DDL operations
During data redistribution and migration, and for 7 calendar days after migration completes, the following DDL operations are blocked:
ADD COLUMN, MODIFY COLUMN, DROP COLUMN, TRUNCATE TABLE, TRUNCATE PARTITION, ALTER BINLOG ENABLE, ALTER BINLOG TTL
Schedule the shard change for a time when these operations are not needed.
What happens during the process
The shard change goes through three stages:
-
Data redistribution and migration — The system redistributes and migrates data across shards. Duration scales with data volume. Read and write operations remain available throughout this stage.
-
Cluster switchover — The system switches the cluster to the new shard configuration. During the early period of switchover, read and write operations remain available. As switchover nears completion, the cluster may enter a read-only state for up to 120 seconds while data synchronization finishes.
-
Complete — The cluster returns to the Running state with the new shard count in effect.
Make sure your application has automatic reconnection enabled to handle transient connections during switchover.
Control the switchover time
By default, switchover starts immediately after migration completes. To defer switchover to a specific time window, connect to the cluster and run:
SET adb_config REPLICATION_SWITCH_TIME_RANGE=`23:00,23:30`;
Enclose the time value in backticks (` `), not single quotation marks ('`).
For instructions on connecting to your cluster, see Connect to an AnalyticDB for MySQL cluster.
Change the shard count
-
Submit a ticket to evaluate the appropriate shard count for your cluster. Proceed to the following steps only after the evaluation confirms that your cluster meets the requirements for a shard change.
-
Log on to the AnalyticDB for MySQL console. In the upper-left corner, select a region. In the left navigation pane, click Switch Immediately.
-
On the Switch at Specified Time tab, find your cluster. In the More column, choose Actions > Change Shards.
-
In the OK dialog box, configure the following parameters: Update Time options:
-
Switch Immediately — Triggers switchover as soon as migration completes.
-
Switch Within Maintenance Window — Defers switchover to the next maintenance window after migration completes. If migration is not complete when a window starts, it continues until the next window.
-
Switch at Specified Time — Triggers switchover at a specified time. If migration is not complete by then, it continues and switchover occurs after migration finishes.
Parameter Description Desired Shards The target shard count for the cluster Update Time When to trigger the cluster switchover after migration completes. Options: Switch Immediately (default), Switch Within Maintenance Window, or Switch at Specified Time -
-
Click OK. The system starts data redistribution and migration.
After the process completes, the cluster returns to the Running state and the new shard count takes effect. To verify, check the cluster status on the Data Warehouse Edition tab.