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.
-
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– Neil Lunn2014年04月29日 02:10:30 +00:00Commented Apr 29, 2014 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– ivica2014年04月29日 08:29:49 +00:00Commented Apr 29, 2014 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– ivica2014年04月29日 09:06:55 +00:00Commented Apr 29, 2014 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?
Sounds like something for capped collections. Doesn't limit the database itself but does limit the collections?
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.