mongo MongoDB shell version: 2.6.6 connecting to: test > use test switched to db test > show collections articles books chenfeng dsf ..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

MongoDB Drop集合不釋放磁盤空間的解決辦法

發(fā)布時(shí)間:2020-08-13 02:33:18 來源:ITPUB博客 閱讀:901 作者:wg0411 欄目:關(guān)系型數(shù)據(jù)庫(kù)
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ì)把不需要的空間釋放出來

> 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.
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI