During database O&M, it is important to identify and resolve storage-related issues at the earliest opportunity. Database Autonomy Service (DAS) provides the storage analysis feature. You can use this feature to view the storage usage of a database instance and the storage information about each table in a database. This helps you identify storage exceptions at the earliest opportunity. DAS also allows you to recycle tablespace fragments to prevent disk space waste and performance degradation.
Prerequisites
The database instance that you want to manage is of one of the following types:
Self-managed MongoDB database
ApsaraDB for MongoDB instance
Only ApsaraDB for MongoDB replica set or sharded cluster instances of specific versions are supported. For more information, see the following table.
Major version
Minor version
Supported
MongoDB 4.0
3.0.x
Not supported
MongoDB 4.2
4.0.0 to 4.0.22
Not supported
4.0.23 and later
Supported
MongoDB 4.4 that uses Database File System (DBFS)
All
Not supported
MongoDB 4.4
5.0.0 to 5.0.6
Not supported
5.0.7 and later
Supported
MongoDB 5.0
All
Supported
MongoDB 6.0
All
Supported
The database instance is connected to DAS and is in the Normal Access state. For more information, see Database Instances.
View information on the Storage Analysis page
Log on to the DAS console.
In the left-side navigation pane, click Instance Monitoring.
On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.
In the left-side navigation pane, click Storage Analysis. On the page that appears, click the Storage Overview or Data Space tab. On the Storage Overview tab, you can view the storage statistics, exceptions, and storage trend of the instance. On the Data Space tab, you can view the storage usage.
Tab
Section
Description
Storage Overview
Storage
You can view information such as exceptions, the average daily increase in space usage within the previous seven days, the number of days for which the remaining storage space is available, and the total amount of used space.
NoteYou can move your pointer over the
icon to view the details of each item.
Exceptions
You can view the exception information about tables or collections in the database instance.
Storage Trend
You can view the usage trend within a specific time range.
NoteThe time range can be up to seven days.
Tablespaces
You can view the detailed information and storage usage of each table in the database instance. You can click the name of a table to view the fields and indexes of the table.
Data Space
You can view the storage usage of each database in the database instance and the usage of tablespaces in the database.
You can click the name of a table to view the fields and indexes of the table.
Recycle tablespace fragments
You can recycle tablespace fragments only of a hidden node. If you want to recycle tablespace fragments of a primary or secondary node, you must switch the primary or secondary node to the hidden node and then recycle tablespace fragments of the new hidden node. Alternatively, you can run the compact
command on the tablespace fragments. For more information about how to switch nodes, see Primary/Secondary switchover. For more information about how to run the compact command, see Defragment the disks of an instance to increase disk utilization.
If the cache eviction
error is reported during the recycling process, it indicates that the instance experienced cache pressure during the compact operation and exited prematurely. You can choose to reschedule the task at a different time. If the task fails multiple times, submit a ticket.
Log on to the DAS console.
In the left-side navigation pane, click Instance Monitoring.
On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.
In the left-side navigation pane, click Storage Analysis.
In the Tablespaces section, find the table that you want to manage. Click Recycle in the Fragmentation Rate column.
In the Recycle dialog box, create the tablespace fragment recycling plan.
Automatic tablespace fragment recycling
If you configure a plan to automatically recycle tablespace fragments for the instance, DAS automatically detects the collections of hidden nodes during the specified maintenance window, and then runs the
compact
command on the collections in which the sum of index and data storage usage exceeds 1 GB and the fragmentation rate is greater than 20%. To reduce the recycling time, the total amount of recyclable space in collections on each hidden node in a recycling plan each round cannot exceed 100 GB. If the recyclable space of a common table exceeds 100 GB, you must manually recycle tablespace fragments of the table.Manual tablespace fragment recycling
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 recycle the tablespace fragments by selecting Execute Now or Run in the O & M window.
NoteThe recycling operation is not immediately complete. In actual situations, DAS runs the
compact
command in the backend for a period of time to gradually recycle the tablespace fragments. The recycling period depends on the size of the tablespace fragments to be recycled. More tablespace fragments require a longer recycling period.We recommend that you recycle up to 10 collections at a time and initiate the next recycling task after the current recycling task is complete. Otherwise, the recycling task may fail.
If the fragmentation rate of a collection is relatively small, the collection may be recycled in a less effective manner.
If the number of collections with relatively small recyclable space is large, we recommend that you configure a plan to automatically recycle tablespace fragments of the collections. If the recyclable space of a collection is relatively large, we recommend that you manually recycle tablespace fragments of the collection. If the recyclable space of a collection exceeds 100 GB, it may take more than 1 hour to recycle tablespace fragments of the collection. Appropriately arrange the recycling time.
View the recycling results
After the recycling task is complete, click Re-analyze to view the results.
References
The storage analysis feature is supported only for MongoDB replica set or sharded cluster database instances whose database version is MongoDB 4.0 or later. For more information about how to recycle tablespace fragments of other MongoDB instances, see Defragment the disks of an instance to increase disk utilization.
Related API operations
Operation | Description |
Creates a storage analysis task to query the usage details of databases and tables. | |
Queries the status and results of a storage analysis task. |