Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution of not releasing disk space in MongoDB Drop collection

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

C:\ Users\ duansf > mongo

MongoDB shell version: 2.6.6

Connecting to: test

> use test

Switched to db test

> show collections

Articles

Books

Chenfeng

Dsf

Fs.chunks

Fs.files

System.indexes

System.profile

Test

Users

> db.books.drop ()

True

>

Delete the collection of books, but check the data file and find that the size remains the same, and MongoDB will not automatically free the file space.

After db.repairDatabase () / / executes this command, Mongodb frees up unwanted space

> db.repairDatabase ()

{"ok": 1}

>

Note: locks will occur during repairDatabase. It is recommended to close the application before performing this operation.

The official documentation interprets this command as follows:

RepairDatabase requires free disk space equal to the size of your current data set plus 2 gigabytes. If the volume that holds dbpath lacks sufficient space

You can mount a separate volume and use that for the repair. When mounting a separate volume for repairDatabase you must run repairDatabase from the command

Line and use the-- repairpath switch to specify the folder in which to store temporary repair files.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report