国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MongoDB > 正文

Mongodb批量刪除gridfs文件實(shí)例

2020-10-29 18:52:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

平臺(tái)有大量的圖片已經(jīng)不用了,數(shù)量級(jí)達(dá)到百萬(wàn)張,差不多100G的空間,放著不管是不是太浪費(fèi)了?

復(fù)制代碼 代碼如下:

db.fs.files.find({filename:/xxx/}).forEach(function(n) {db.fs.files.update({filename:u.filename},{$set:{filename:newname}},false,true)}} //正則批量更改為固定名稱(chēng),便于刪除。
mongofiles -port 12345 -d xxx delete newname //mongofies根據(jù)filename批量干掉這些文件。

db.repairDatabase() //特別注意以上刪除不是物理刪除,chunks文件實(shí)際還在,show dbs 或者 db.stats() 發(fā)現(xiàn)db的size沒(méi)有變化,要執(zhí)行db.repairDatabase();另外注意這個(gè)動(dòng)作是全局寫(xiě)鎖,很耗內(nèi)存和cpu的,而且處理時(shí)間跟文件數(shù)量大小有關(guān),務(wù)必在非高峰期做。


差不多1個(gè)多小時(shí)后over, 舒坦了,100G空間?。。?!

Be aware that this command can take a long time to run if your database is large. In addition, it requires a quantity of free disk space equal to the size of your database. If you lack sufficient free space on the same volume, you can mount a separate volume and use that for the repair. In this case, you must run the command line and use the

主站蜘蛛池模板: 凌源市| 涪陵区| 长汀县| 彭阳县| 象州县| 朝阳县| 商丘市| 东丰县| 巧家县| 资讯 | 台南县| 买车| 文化| 庆阳市| 石河子市| 宁夏| 监利县| 西安市| 渝中区| 许昌县| 积石山| 应城市| 宁蒗| 舞钢市| 河西区| 绥化市| 陇川县| 平遥县| 永福县| 镶黄旗| 开原市| 禄劝| 家居| 垦利县| 双鸭山市| 怀来县| 六安市| 拉萨市| 湘乡市| 盐城市| 乡宁县|