The platform has a large number of pictures have been used, the order of magnitude of millions, almost 100G of space, whether it is too wasteful?
Copy Code code as follows:
Db.fs.files.find ({filename:/xxx/}). ForEach (function (n) {db.fs.files.update {filename:u.filename},{$set: { filename:newname}},false,true)}//Regular batch is changed to a fixed name for easy deletion.
Mongofiles-port 12345-d xxx Delete newname//mongofies to kill these files according to the filename in batches.
Db.repairdatabase ()///special Note that the above deletion is not a physical deletion, chunks file is actually still in, show DBS or db.stats () found that the size of DB has not changed, to perform db.repairdatabase () Note that this action is a global write lock, memory and CPU consumption, and processing time is related to the size of the file, be sure to do during off-peak hours.
Almost 1 hours later over, comfortable, 100G space Ah!!!
The
is aware the This command can take a long time to run if your the database is large. In addition, it requires a quantity of free disk spaces equal to the size of your database. If you are lack sufficient free spaces on the same volume, your can mount a separate volume and use this 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 TEM Porary repair files.
Warning:this Command obtains a global write lock and would block other operations until it has completed.