-rw------- 1 root wheel 67108864 8 16 13:49 video.0
-rw------- 1 root wheel 134217728 8 16 13:48 video.1
-rw------- 1 root wheel 268435456 8 16 13:48 video.2
-rw------- 1 root wheel 536870912 8 16 13:48 video.3
-rw------- 1 root wheel 1073741824 8 16 13:49 video.4
-rw------- 1 root wheel 2146435072 8 16 13:49 video.5
-rw------- 1 root wheel 16777216 8 16 13:49 video.ns
我感觉 video.ns 是 video.0 到 video.5 是一个增长的过程 感觉最新的数据就是 video.5 请问其他的数据是可以删掉的吗? 我之前用了rm的命令去删除,之后启动mongo会报错说数据被破坏,这种方式估计是有问题的,想问下有什么其它的方式去释放这些空间。。。。
天蓬老师2017-05-02 09:23:52
If you calculate it carefully,
video.0 = 64MB
video.1 = 128MB
video.2 = 256MB
...
video.5 = 2GB
This is the way the MMAPv1 engine allocates space, 2 to the nth power, and it will not grow after 2GB. Each file contains actual data and cannot be deleted casually
To be honest, why would you think of deleting database files directly? No database seems to support this approach. If you want to free up space, a safer approach should be to consider replica set resynchronization, or repairDatabase. The latter has many limitations, please read the documentation carefully.
In addition, if you have not deleted data on a large scale, there is no need to perform the above two operations, because no space will be released anyway.