MongoDB 插入失败"error inserting documents: new file allocation failure"



我使用bash脚本进行插入:

for i in *.json
do 
    mongoimport --db testdb --collection test --type json --file $i --jsonArray
done

现在我的数据库testdb是5.951GB,终端一直给我错误

插入文档时出错:新文件分配失败

一个集合中可以保存多少数据?我处理这个问题的最佳方法是什么?我目前有 20GB 的数据,但我还有另外 40GB 的数据要添加。

-更新-

这是我的极限状态:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31681
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31681
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Mongo可以在一个集合中处理数十亿个文档,但最大文档大小为16m。创建集合时,可以设置其大小:

db.createCollection( "collection-name", { capped: true, size: 100000 } )

Mongo 提供批量 API,如果你必须在集合中插入多个文档:批量写入操作

最新更新