All Products
Search
Document Center

ApsaraDB for MongoDB:Storage analysis

Last Updated:Oct 10, 2024

This topic describes how to view the storage overview of an ApsaraDB for MongoDB instance by using the storage analysis feature of CloudDBA. The storage analysis feature provides an overview of the storage usage of an instance. The feature also provides information about the storage that is occupied by each object on the instance and allows you to defragment a disk. You can use the storage analysis results to identify and troubleshoot storage exceptions. This ensures the stable performance of the instance.

Prerequisites

The storage analysis feature is supported by replica set or sharded cluster instances. The following table describes whether the MongoDB versions of the replica set or sharded cluster instances support the feature.

Major engine version

Minor engine version

Support for storage analysis

MongoDB 4.0

MongoDB 3.0.x

No

MongoDB 4.2

MongoDB 4.0.0 to MongoDB 4.0.22

No

MongoDB 4.0.23 or later

Yes

MongoDB 4.4

MongoDB 5.0.0 to MongoDB 5.0.6

No

MongoDB 5.0.7 or later

Yes

MongoDB 5.0

All

Yes

MongoDB 6.0

All

Yes

MongoDB 7.0

All

Yes

Usage notes

If you want to use the storage analysis feature of CloudDBA as a Resource Access Management (RAM) user, make sure that the RAM user is granted the AliyunHDMFullAccess or AliyunHDMReadOnlyAccess permission on Database Autonomy Service (DAS). For more information, see How do I use DAS as a RAM user?

View the storage overview

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Replica set instances or Sharded cluster instance based on the instance type.

  3. In the upper-left corner of the page, select the resource group and region to which an instance belongs.

  4. Click the ID of the instance or click Manage in the Actions column.

  5. In the left-side navigation pane of the instance details page, choose CloudDBA > Storage Analysis.

  6. View the storage analysis results.

    • View the storage overview of namespaces

      Click the Storage Overview tab to view the following information:

      • In the Storage section, view the storage overview.

        Metric

        Description

        Exception

        The number of storage exceptions that are identified in the instance. ApsaraDB for MongoDB can identify the following types of exceptions:

        • More than 90% of the storage is used.

        • The available physical storage may be exhausted within seven days.

        • A single collection contains more than 10 indexes.

        Avg Daily Increase in Last Week

        The average daily increase of storage usage in the instance in the last seven days.

        Formula: (Size of available storage at the time of collection - Size of available storage seven days ago)/7.

        Note
        • This increase indicates the average daily increase in the last seven days at the time of collection.

        • This parameter is suitable for scenarios in which the traffic volume remains stable. The value of this parameter becomes inaccurate when storage abruptly changes due to operations such as batch import, deletion of historical data, instance migration, or instance rebuilding.

        Available Days of Storage

        The number of days during which storage is available in the instance.

        Formula: Size of available storage/Average daily increase in the last seven days.

        Note
        • The value 90+ indicates that the available storage in the instance is sufficient for a long period of time.

        • This parameter is suitable for scenarios in which the traffic volume remains stable. The value of this parameter becomes inaccurate when storage abruptly changes due to operations such as batch import, deletion of historical data, instance migration, or instance rebuilding.

        Used Storage

        The amount of storage space that is used by the instance and the total storage space.

      • In the Exceptions section, view the information of storage exceptions. You can troubleshoot the exceptions based on the information.

      • In the Storage Trend section, view the data trends in the last week.

      • In the Tablespaces section, view the data of collections.

        Note

        You can click the name of a collection to view its indexes.

    • View the storage overview of a data space

      Click the Data Space tab to view the following information:

      • You can click the name of a data space to view its namespace information.

      • You can click the name of a collection to view its indexes.

Defragment a disk

Important

You can defragment a disk of only a hidden node. If you want to defragment a disk of the primary node or a secondary node, you can switch the primary node or the secondary node to the hidden node and then defragment a disk of the hidden node. You can also execute the compact statement described in Defragment a disk to improve disk usage. For more information about how to perform a primary/secondary switchover, see Primary/Secondary failover.

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Replica set instances or Sharded cluster instance based on the instance type.

  3. In the upper-left corner of the page, select the resource group and region to which an instance belongs.

  4. Click the ID of the instance or click Manage in the Actions column.

  5. In the left-side navigation pane of the instance details page, choose CloudDBA > Storage Analysis.

  6. In the Tablespaces section of the page that appears, find the collection that you want to manage. Then, click Recycle in the Fragmentation Rate column.

  7. In the Recycle dialog box, complete related settings.

    • Automatic defragmentation

      If you configure a plan to automatically defragment a disk for the instance, DAS automatically detects the collections of hidden nodes during the specified maintenance window, and then runs the compact command on collections in which the sum of index and data storage usage exceed 1 GB and the fragmentation rate is greater than 20%. To reduce defragmentation time, the total amount of recyclable space in collections on each hidden node in a defragmentation plan each round cannot exceed 100 GB. If the recyclable space of a common collection exceeds 100 GB in size, you must manually defragment a disk of the collection.

    • Manual defragmentation

      In the Collection with High Fragmentation Rate section, find the collection that you want to manage and click Recycle in the Actions column. You can defragment a disk by selecting Execute Now or Run in the O & M window.

    Note
    • After the operation is complete, the disk is not immediately defragmented. Wait for a few minutes. In practice, the compact command continues to run in the background for a period of time to gradually defragment a disk. The defragmentation time depends on the size of the storage to be defragmented. A larger storage requires a longer defragmentation time.

    • We recommend that you concurrently defragment the disks of up to 10 collections and wait until the current defragmentation task is completed before you start the next task. If you start the next task before the current task is completed, the defragmentation task may fail.

    • If the fragmentation rate of a collection is relatively low, the defragmentation process for the collection may not recycle a large size of storage.Fragmentation Rate

    • If the number of collections with relatively small recyclable space is large, we recommend that you configure a plan to automatically defragment the disks of the collections. If the recyclable space of a collection is relatively large, we recommend that you manually defragment a disk of the collection.Recyclable SpaceRecyclable Space If the Recyclable Space value of a collection exceeds 100 GB in size, the time required to defragment a disk of the collection may exceed 1 hour.

View defragmentation results

After the defragmentation task is complete, click Re-analyze to view the results.

FAQ

What do I do if the (Interrupted) Compaction interrupted on table:*** due to cache eviction pressure error message appears?

The instance whose disks you want to defragment is of an earlier version and has low specifications. When you run the compact command on the instance, the instance fails due to a large amount of cached data. If a defragmentation task fails, you can select a time to restart the task. If the task fails multiple times, submit a ticket.

References

The storage analysis feature is supported only for ApsaraDB for MongoDB replica set or sharded cluster instances that run MongoDB 4.0 or later. For more information about how to defragment the disks of ApsaraDB for MongoDB instances that run MongoDB versions earlier than MongoDB 4.0, see Defragment a disk to improve disk usage.

Related tasks

The storage analysis feature of CloudDBA can analyze up to 20,000 collections. If no storage analysis results are displayed, you can check whether the number of collections exceeds 20,000 or whether your account is granted permissions on the specified collections. If your account is not granted permissions, you can use one of the following methods to grant your account permissions on the specified collections:

  • Grant an existing account permissions

    1. In the upper section of the instance storage analysis page, click Re-authorize.

    2. Enter the username and password of the account in the Database Account and Password fields.

    3. Click OK.

  • Grant the current account permissions by running a command

    1. In the upper section of the instance storage analysis page, click Re-authorize.

    2. Enter the username and password of the account in the Database Account and Password fields.

    3. Click Generate Authorization Command.

    4. Click OK.

Related API operations

Operation

Description

CreateStorageAnalysisTask

Creates a storage analysis task to query the usage details of one or more databases and collections.

GetStorageAnalysisResult

Queries the status and results of a storage analysis task.