CloudDBA storage analysis provides an overview of storage usage, trends, and exceptions for your ApsaraDB for MongoDB instance. You can identify storage anomalies and reclaim space by defragmenting disks to keep your instance stable.
Prerequisites
Your ApsaraDB for MongoDB replica set or sharded cluster instance must meet the following version requirements.
Major version | Minor version | Supported |
MongoDB 4.0 | 3.0.x | No |
MongoDB 4.2 | 4.0.0-4.0.22 | No |
>= 4.0.23 | Yes | |
MongoDB 4.4 | 5.0.0-5.0.6 | No |
>= 5.0.7 | Yes | |
MongoDB 5.0 | All | Yes |
MongoDB 6.0 | All | Yes |
MongoDB 7.0 | All | Yes |
MongoDB 8.0 | All | Yes |
Usage notes
If you use a RAM user to access CloudDBA storage analysis, make sure the RAM user has the AliyunHDMFullAccess or AliyunHDMReadOnlyAccess permission. For more information, see How do I use DAS as a RAM user?
Analyze storage
Log on to the ApsaraDB for MongoDB console.
In the navigation pane on the left, click Replica Set Instances or Sharded Cluster Instance, depending on your instance type.
In the upper-left corner of the page, select the resource group and region where your instance is located.
Find the target instance and click its ID, or click Manage in the Actions column.
In the navigation pane on the left, click .
You can view the storage overview of your database.
View the storage overview of databases and tables
Click the Storage Overview tab to view the following information:
In the Storage section, view the storage overview.
Metric
Description
Exception
The following conditions are considered exceptions:
The storage usage of the instance exceeds 90%.
The estimated remaining days of physical storage for databases and tables is less than 7.
The number of indexes in a single collection exceeds 10.
Avg Daily Increase in Last Week
The average daily increase in storage usage over the past seven days.
Formula: (Storage size at collection time - Storage size seven days ago)/7.
NoteThe growth rate is the seven-day average at the time of data collection.
This metric is suitable for services with stable workloads. Sudden storage changes, such as batch data imports, historical data deletion, or instance migration and recreation, can make this metric less accurate.
Available Days of Storage
The estimated number of days before available storage runs out. The remaining storage is also displayed.
Formula: Available space / Avg daily increase in last week.
NoteA value of 90+ indicates that disk space is predicted to be sufficient for a long time.
This metric is suitable for services with stable workloads. Sudden storage changes, such as batch data imports, historical data deletion, or instance migration and recreation, can make this metric less accurate.
Used Storage
The used storage compared to the total storage size.
In the Exceptions section, view exception details to troubleshoot storage issues.
In the Storage Trend section, view the storage usage trend for databases and tables over the past week.
In the Tablespace section, view data information for each collection.
NoteYou can click a collection name to view its index information.
View data and tablespace overview
Click the Data Storage tab to view the following information:
Click a data space name to view its tablespace information.
Click a collection name to view its index information.
Defragment disks
You can defragment disks only for a hidden node. To defragment disks for a primary or secondary node, you must first perform a primary/secondary switchover to change the primary or secondary node to a hidden node, and then defragment its disks. Alternatively, you can run the compact command directly. For more information, see Defragment disks to improve disk utilization. Important: Read the referenced document carefully before you proceed.
Log on to the ApsaraDB for MongoDB console.
In the navigation pane on the left, click Replica Set Instances or Sharded Cluster Instance, depending on your instance type.
In the upper-left corner of the page, select the resource group and region where your instance is located.
Find the target instance and click its ID, or click Manage in the Actions column.
In the navigation pane on the left, click .
In the Tablespaces section, click Recycle in the Fragmentation Rate column.
In the Recycle dialog box, defragment disks.
Configure a defragmentation schedule.
After you configure a defragmentation schedule for the instance, DAS automatically scans all collections on the hidden node during the daily maintenance window. It runs the
compactcommand on collections where the combined size of data space and index space exceeds 1 GB and the fragmentation rate exceeds 20%. To prevent the operation from taking too long, the total recyclable space for all collections on each hidden node is capped at 100 GB per round. If the recyclable space of a single collection exceeds 100 GB, you must run the defragmentation task manually.Manually defragment disks.
In the list of collections with a high fragmentation rate, find the target collection and click Recycle in the Actions column. Then, select Execute Now or Run in the O&M window to begin reclaiming space.
NoteAfter you start the task, disk defragmentation is not completed immediately. The
compactcommand runs in the background and gradually reclaims fragmented space. The duration depends on the amount of recyclable space — the more space to reclaim, the longer the process takes.Avoid defragmenting more than 10 collections at the same time. Wait for each task to complete before starting the next to prevent failures.
If the Fragmentation Rate of the target collection is low, defragmentation may not yield significant results.
Use a defragmentation schedule to process many collections with small amounts of Recyclable Space. For collections with large amounts of Recyclable Space, run the task manually. When a collection's Recyclable Space exceeds 100 GB, the process may take more than one hour. Plan the schedule accordingly.
Defragmentation results
After the defragmentation task is complete, click Re-analyze to view the results.
The effectiveness of defragmentation depends on data distribution. If the result is unsatisfactory, you can run the task again.
FAQ
Q: What do I do if I receive the error (Interrupted) Compaction interrupted on table:*** due to cache eviction pressure ?
A: This error indicates that the compact operation was interrupted due to cache pressure on a low-specification instance running an earlier version. If a defragmentation task fails, try running it again at a different time. If the task fails repeatedly, submit a ticket.
References
Storage analysis is available only for ApsaraDB for MongoDB replica set and sharded cluster instances that run MongoDB 4.0 or later. To defragment disks for instances that run earlier MongoDB versions, see Defragment disks to improve disk utilization.
Related tasks
If storage data is missing, your account may lack the required permissions on the databases and collections, or the number of collections may exceed the limit. To resolve this, re-authorize access using one of the following methods:
Use an existing account and password
Click Re-authorize at the top of the page.
Enter the Database Account and Password.
Click Confirm.
Generate an authorization command
Click Re-authorize at the top of the page.
Enter the Database Account and Password.
Click Generate Authorization Command.
Click Confirm.
API reference
API | Description |
Creates a storage analysis task to obtain storage usage data for databases and collections. | |
Queries the status and results of a storage analysis task. |