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

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

Mongodb批量刪除gridfs文件實例

2020-03-14 13:22:54
字體:
供稿:網(wǎng)友
這篇文章主要介紹了Mongodb批量刪除gridfs文件實例,本文根據(jù)生產(chǎn)環(huán)境實際需求總結(jié)而來,需要的朋友可以參考下
 

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

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

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

 

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


差不多1個多小時后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 –repairpath switch to specify the folder in which to store the temporary repair files.
Warning:This command obtains a global write lock and will block other operations until it has completed.


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 全南县| SHOW| 红原县| 儋州市| 淮南市| 本溪市| 宜丰县| 庆安县| 乌兰察布市| 昔阳县| 儋州市| 平顶山市| 闸北区| 安国市| 博野县| 乌拉特前旗| 宕昌县| 涿鹿县| 金昌市| 华亭县| 永胜县| 梧州市| 石狮市| 瓦房店市| 鄯善县| 太和县| 房产| 四川省| 江山市| 读书| 兴宁市| 独山县| 积石山| 大城县| 博乐市| 郴州市| 宿松县| 时尚| 静安区| 仁寿县| 抚顺市|