MongoDB insertion failure "error inserting documents: new file allocation failure"

I used a bash script to do the insertion:

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

Now my database testdb is 5.951GB and the terminal keeps giving me the error

error inserting documents: new file allocation failure

How much data can I hold in one collection? What is the best way for me to handle this? I currently have 20GB worth of data but I will have another 40GB data to be added.


Here's my ulimit status:

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 can handle billions of documents in one collection but the maximum document size is 16m. When you create a collection you can set his size:

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

Mongo provide a bulk api if you have to insert multiples document in a collection: bulk-write-operations


 ? SIGINT SIGQUIT Bash script
 ? Bash script csv manipulation optimization
 ? Check if a file exist in FTP with an automated bash script
 ? Are quotes around $() unnecessary?
 ? how to hide warning in bash script
 ? Start process and wait until logfile has specific entry
 ? Convert Thread Process Id to Hex format
 ? execute remote command on remote windows via linux while escaping quotes
 ? how to change pattern in file's line
 ? How to connect Database and run query inside a shell script?