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
>
刪除books這個(gè)collection,但是查看數(shù)據(jù)文件發(fā)現(xiàn)大小不變,MongoDB不會(huì)自動(dòng)釋放文件空間
db.repairDatabase() //執(zhí)行這個(gè)命令后,Mongodb會(huì)把不需要的空間釋放出來(lái)
> db.repairDatabase()
{ "ok" : 1 }
>
注意:repairDatabase期間會(huì)產(chǎn)生鎖,建議關(guān)閉應(yīng)用后再進(jìn)行此操作
官方文檔對(duì)這個(gè)命令的解釋如下:
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.
網(wǎng)站題目:MongoDBDrop集合不釋放磁盤(pán)空間的解決辦法
文章鏈接:
http://weahome.cn/article/giiecp.html