Logs are automatically deleted when their size reaches a specific threshold.
In emergencies, you can run the
compactcommand to delete oplogs. For more information, see Defragment the disk space to improve disk usage.
- You can only run this command on replica set instances.
- Before running
compact, you must log on to the local database where the oplog.rs collection is stored.