All Products
Search
Document Center

AnalyticDB:Change the number of shards

Last Updated:May 12, 2025

The number of shards determines the horizontal scaling capability of an AnalyticDB for MySQL cluster. If the initial number of shards in an AnalyticDB for MySQL cluster leads to issues, such as write performance degradation, query performance bottlenecks, and resource scaling limits, you can change the number of shards to prevent impacts on your business.

Prerequisites

  • An AnalyticDB for MySQL Data Warehouse Edition cluster is created.

    Note

    You cannot change the number of shards for Data Warehouse Edition clusters that have the S16 or S8 specifications.

  • The minor version of the AnalyticDB for MySQL cluster is 3.2.3.0 or later.

    Note

    To view and update the minor version of an AnalyticDB for MySQL cluster, log on to the AnalyticDB for MySQL console and go to the Configuration Information section of the Cluster Information page.

  • The AnalyticDB for MySQL cluster is in the Running state.

  • The number of shards is not changed for the AnalyticDB for MySQL cluster.

Limits

You cannot change the number of shards for an AnalyticDB for MySQL cluster that meets one of the following conditions:

  • No databases or tables other than the default database are created.

  • A table whose table engine is XUANWU_V2 exists.

  • A materialized view that is incrementally updated exists.

Usage notes

  • You can change the number of shards for an AnalyticDB for MySQL cluster only once. Proceed with caution when you evaluate the suitable number of shards to ensure that the specified number of shards provides the best business performance.

  • After you specify a new number of shards in the AnalyticDB for MySQL console, the system starts to redistribute and migrate data. The amount of time required for data redistribution and migration is proportional to the amount of data.

  • During the data redistribution and migration process and within seven calendar days after data migration is complete, the following operations are prohibited: ADD COLUMN, MODIFY COLUMN, DROP COLUMN, TRUNCATE TABLE, TRUNCATE PARTITION, ALTER BINLOG ENABLE, and ALTER BINLOG TTL. If your business requires the preceding operations, we recommend that you change the number of shards during an appropriate period of time based on your business requirements.

  • During the data redistribution and migration process and the early period of the cluster switchover, you can read and write data as expected. When the cluster switchover is about to end, the cluster may encounter transient connections and remain in the read-only state within 120 seconds to ensure that all data is synchronized. We recommend that you set the Update Time parameter of your cluster to off-peak hours and make sure that your applications can be automatically reconnected to your cluster.

  • If you want to change the switchover time for an AnalyticDB for MySQL cluster before the cluster switchover starts, connect to the cluster and execute the following statement. In this example, the specified switchover window is 23:00 to 23:30.

    Important

    Make sure that you enclose the time parameter value in backticks (``), but not in single quotation marks ('').

    SET adb_config REPLICATION_SWITCH_TIME_RANGE=`23:00,23:30`;

    For information about how to connect to an AnalyticDB for MySQL cluster, see Connect to an AnalyticDB for MySQL cluster.

Procedure

  1. Submit a ticket to evaluate the suitable number of shards for your AnalyticDB for MySQL cluster.

    If your AnalyticDB for MySQL cluster meets the change requirements after the evaluation, continue the subsequent steps.

  2. Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters.

  3. On the Data Warehouse Edition tab, find the AnalyticDB for MySQL cluster that you want to manage and choose More > Change Shards in the Actions column.

  4. In the Change Shards dialog box, configure the Desired Shards and Update Time parameters.

    Parameter

    Description

    Desired Shards

    The number of shards that you want to configure for the AnalyticDB for MySQL cluster.

    Update Time

    The point in time at which you want to start the cluster switchover. Valid values:

    • Switch Immediately (default): immediately triggers the cluster switchover after the data redistribution and migration process is complete.

    • Switch Within Maintenance Window: switches the cluster within the specified maintenance window. For more information about the maintenance window, see Configure a maintenance window. If the data redistribution and migration process is not complete when a maintenance window is reached, the process continues. If the process is complete when the next maintenance window is reached, the system triggers the cluster switchover.

    • Switch at Specified Time: switches the cluster at the specified point in time. If the data redistribution and migration process is not complete when the specified point in time is reached, the process continues. After the process is complete, the system triggers the cluster switchover.

  5. Click OK. The system starts to redistribute and migrate data. The amount of time required for data redistribution and migration is proportional to the amount of data. During the data redistribution and migration process and the early period of the cluster switchover, you can read and write data as expected.