Decreasing the Storage of a DB System

You cannot decrease the storage size of a DB system through the Console or CLI. You must use the export and import method to migrate the data to a newly created DB system with a smaller storage size.

Note

The allocated storage size affects the storage performance of the DB system. The initial storage size of the new DB system determines the number of storage volume and can restrict the storage performance if the storage size is increased tremendously later. See DB System Storage.

Using Export and Import Method

To decrease the storage size of a DB system, export the data of the DB system and import it into a new DB system created with a smaller storage size.

Do the following to decrease the storage of a DB system:
  1. Stop all applications that may change the data stored in the DB system.
  2. Export the DB system to an Object Storage bucket. See Exporting a MySQL Instance.
  3. Create a new DB system with a smaller storage size and import the data. See Importing Using the Data Import Feature.
  4. Restart and switch all applications to connect to the new DB system endpoint.
  5. Delete the original DB system if it is no longer required.

Using Replication Method

You can use the replication method to reduce the downtime for switching the application from the original DB system to the new DB system with a smaller storage size.

Do the following to decrease the storage of a DB system with minimal downtime:
  1. Export the DB system to an Object Storage bucket. See Exporting a MySQL Instance.
  2. Create a new DB system with a smaller storage size and import the data. See Importing Using the Data Import Feature.
  3. Create a replication user on the original DB system. See Creating a Replication User On a Source Server.
  4. Create a replication channel on the new DB system with the original DB system as the source server. See Creating a Replication Channel.
    Note

    Select enabled automatically upon creation, configure the original DB system in the source connection, use GTID in replication positioning, and select the new DB system as the target DB system.
  5. After the channel has been created and is in the active state, monitor the channel metrics named Inbound channel lag. See Monitoring Channel Metrics.
  6. When the lag is close to or equal to 0, stop all applications that connect to the original DB system.
  7. Use MySQL Shell or another MySQL client program to connect to the new DB system and run the following SQL statement:
    SHOW REPLICA STATUS \G
    Run the same command until the following columns show the values in this table:
  8. Restart and switch all applications to connect to the new DB system endpoint.
  9. Delete the replication channel. See Deleting a Channel.
  10. Delete the original DB system if it is no longer required.