How to defragment the mongodb database without downtime?
習慣沉默
習慣沉默 2017-05-02 09:22:51
0
1
780

After I deleted a large amount of redundant data in mongo, I found that the memory and files did not shrink. They still occupied a lot of memory and hard disk, and the performance did not change much. How to defragment mongodb?

習慣沉默
習慣沉默

reply all(1)
洪涛

What version of MongoDB and what engine?
WT engines above 3.2 can use Compact to free up space. Previous versions, whether WT or MMAPv1, could only free up space by resynchronizing the replica set.
The problem is that there is generally no need to release it in a production environment, because it will be occupied sooner or later, and the free space will be reused anyway. If you are not really short of that space, don't release it.
As for whether it is a problem of downtime, it is not just this problem. Most of the time, replica sets should be considered to solve it. Multiple nodes are running in parallel to prepare for no downtime. It will not be a big problem to remove one for maintenance. When you get the main node, it may not be writable for a few seconds.

Theoretically, reclaiming disk space will not have any beneficial impact on performance. However, a bug occurred in the WiredTiger engine used in 3.0.6 and 3.0.7. When a large number of documents were deleted, BTree would have an incorrect balance, resulting in a serious performance degradation. For details, please refer to JIRA Ticket SERVER-21063.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template