您现在的位置是:网站首页> 编程资料编程资料
Mongodb批量删除gridfs文件实例_MongoDB_
2023-05-27
463人已围观
简介 Mongodb批量删除gridfs文件实例_MongoDB_
平台有大量的图片已经不用了,数量级达到百万张,差不多100G的空间,放着不管是不是太浪费了?
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根据filename批量干掉这些文件。
db.repairDatabase() //特别注意以上删除不是物理删除,chunks文件实际还在,show dbs 或者 db.stats() 发现db的size没有变化,要执行db.repairDatabase();另外注意这个动作是全局写锁,很耗内存和cpu的,而且处理时间跟文件数量大小有关,务必在非高峰期做。
差不多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.
- 利用Mongoose让JSON数据直接插入或更新到MongoDB
- JSON 的正确用法探讨:Pyhong、MongoDB、JavaScript与Ajax
- python读取json文件并将数据插入到mongodb的方法
- MongoDB执行mongoexport时的异常及分析(数字类型的查询)
- MongoDB批量将时间戳转为通用日期格式示例代码
- Python实现批量读取图片并存入mongodb数据库的方法示例
- MongoDB单表数据的导出和恢复实例讲解
- MongoDB备份、还原、导出、导入、克隆操作示例
- 深入分析Mongodb数据的导入导出
- MongoDB导出查询结果到文件例子
- mongodb 数据库操作--备份 还原 导出 导入
- MongoDB使用mongoexport和mongoimport命令,批量导出和导入JSON数据到同一张表的实例
相关内容
- Mongodb数据库的备份与恢复操作实例_MongoDB_
- Windows下MongoDB配置用户权限实例_MongoDB_
- mongoDB在windows下安装与配置方案_MongoDB_
- MongoDB错误32-bit servers don't have journaling enabled by default解决方法_MongoDB_
- Windows下把MongoDB安装为系统服务的方法_MongoDB_
- Mongodb启动命令参数中文说明_MongoDB_
- C#实现窗体中的各个控件同比自动放缩大小_MongoDB_
- 十个提高MongoDB安全性的配置技巧_MongoDB_
- MongoDB社区版和企业版的差别对照表_MongoDB_
- MongoDB查询字段没有创建索引导致的连接超时异常解案例分享_MongoDB_
