How to make mongodb database size bigger

mongodb

I have been uploading photos with reports to mongodb. I reached the database size limit. How do I increase the size of the database?

db.stats()
{
        "db" : "fieldops",
        "collections" : 6,
        "objects" : 20454,
        "avgObjSize" : 890464.9997066589,
        "dataSize" : 18213571104,
        "storageSize" : 18432802736,
        "numExtents" : 52,
        "indexes" : 4,
        "indexSize" : 809424,
        "fileSize" : 21398290432,
        "nsSizeMB" : 16,
        "extentFreeList" : {
                "num" : 0,
                "totalSize" : 0
        },
        "dataFileVersion" : {
                "major" : 4,
                "minor" : 22
        },
        "ok" : 1
}

Also, as an aside. I have 12,000 pics right now that are uploaded every month. I read that the mongodb data file limit is 16,000. I couldn't find what the definition of data file is in the glossary. Is that referring to the buffered pictures that I uploaded to the database? So, once that happens I have to set up a separate server with a shard? Or can I create a shard on the same machine?

Thanks in advance.

Best Answer

I have been uploading photos with reports to mongodb. I reached the database size limit. How do I increase the size of the database?

Assuming you have available disk space, MongoDB will automatically allocate additional disk space as required. Since you are running the MMAP storage engine (based on your db.stats() output), MongoDB will preallocate space in increasing increments up to 2GB per new file (or max of 512MB per file if you happen to be using the smallFiles option). Given your database is currently >18GB, you will need at least 2GB of free space (plus some space for the O/S if your temp directory is on the same volume).

There is no limit on document count for a collection unless you happen to be using a capped collection with a specified max limit (which must be less than 2^32). There are MongoDB production deployments with trillions of documents (ref: MongoDB at Scale).

MongoDB 3.0+ has a storage engine API so there may be some limits that vary by storage engine. For example, the limit on data size for a single mongod with the classic MMAPv1 storage engine is typically 64 terabytes of data with journaling enabled. The WiredTiger storage engine (optional in 3.0, default in 3.2+) does not have this limitation.

Inserting tens of thousands of documents per month should not be an issue.

For more information see: MongoDB Limits and Thresholds.

Related Topic