Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Are there any mechanisms to limit the size of a single database on MongoDB 2.6? I found some options like quota, quotaFiles and nssize but am unsure how to use them.

share|improve this question
    
Are you actually trying to restrict the total size of the database? There are several options to limit individual file sizes, but there is nothing to put a hard limit on how big a database will become. –  Neil Lunn Apr 29 at 2:10
    
Yes, I was thinking something like that. My team and I wanted to give our students MongoDB environments with limited size because of storage limits at our university. –  ivica Apr 29 at 8:29
    
Sorry for spamming, can't edit previous comment. We would like to have around 200 databases (one per user) and each should be limited to lets say 256MB. –  ivica Apr 29 at 9:06

3 Answers 3

Ok, it was simple :)

I wanted to limit each database to 256MB of space per student. In order to achieve that, I enabled smallfiles in /etc/mongod.conf and ran the mongod process with mongod -f /etc/mongod.conf --quota --quotaFiles 4 which limited the size of the database to 256MB.

smallfiles starts preallocating space with 16MB, then 32MB, 64MB and finally 128MB. Add this up and you get 240MB plus 16MB file for the namespace = 256MB

This however doesn't stop them from creating another database with the same user. Any help on this?

share|improve this answer

Sounds like something for capped collections. Doesn't limit the database itself but does limit the collections?

http://blog.mongodb.org/post/116405435/capped-collections

share|improve this answer
1  
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  Colin 't Hart May 6 at 12:16

I have the same issue. Mongo does not respect quota. I haven't found the answer, but I found SERVER-5136 . According to this, it is recorded issue but sadly resolution is still not planned.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.