ApsaraDB for MongoDB automatically deletes oplogs when they exceed a size threshold. This topic explains when deletion is triggered and how to manually reclaim disk space in an emergency.
How log deletion works
Log deletion is triggered when oplogs occupy more than 10% of the instance's disk space. Once triggered, oplogs are automatically deleted.
Before performing high-risk operations such as modifying instance configurations or data, check the disaster recovery and fault tolerance capabilities of the instance to ensure data security. Back up your data and enable log backup to protect against data loss. If you have granted permissions to users or submitted sensitive information such as logon usernames or passwords in the Alibaba Cloud Management console, modify that information as soon as possible.
Reclaim disk space manually
To reclaim disk space immediately without waiting for automatic deletion, run the compact command on the oplog.rs collection in an emergency.
Applies to: Replica set instances only.
Before running the command, log in to the local database where the oplog.rs collection is stored.
The db.repairDatabase command is not allowed.
db.runCommand({compact:'oplog.rs'})For more information about freeing up disk space, see Defragment the disk space to improve disk usage.