Stuart Ingram
Stuart Ingram

Reputation: 101

Mongo rs.initiate() excessive disk space requirements

I have 2 mongod instances running with the following parameters

  --noprealloc --smallfiles --replSet mongors1 --dbpath /data/db --nojournal

The goal of the exercise is to create a replicated environment with a minimal disk footprint for local development purposes.

At this point in time, all is good with each respective data system being around ~32M and having the following

ls -o data/db
total 32784
-rw------- 1 999 16777216 Sep 22 11:38 local.0
-rw------- 1 999 16777216 Sep 22 11:38 local.ns
-rwxr-xr-x 1 999        2 Sep 22 11:38 mongod.lock
-rw-r--r-- 1 999       69 Sep 22 11:38 storage.bson
drwxr-xr-x 2 999     4096 Sep 22 11:38 _tmp

After logging on to the first member and running rs.initiate(); an additional 1G of disk space is utilized.

ls -o data/db
total 1080856
-rw------- 1 999  16777216 Sep 22 11:39 local.0
-rw------- 1 999 536608768 Sep 22 11:39 local.1
-rw------- 1 999 536608768 Sep 22 11:39 local.2
-rw------- 1 999  16777216 Sep 22 11:39 local.ns
-rwxr-xr-x 1 999         2 Sep 22 11:38 mongod.lock
-rw-r--r-- 1 999        69 Sep 22 11:38 storage.bson
drwxr-xr-x 2 999      4096 Sep 22 11:39 _tmp

This seems excessive given the properties of the nodes being replicated and the configuration they are running.

Mongo 3.0.6 is the version in use.

Eventually this will be scaled up to replica sets with 3 members across 2+ shards. A minimal disk requirement of 6Gb to store zero data initially seems sub-optimal.

Is there a way to reduce this to something more representative of the nodes needs?

Any help is appreciated. Thanks in advance

Upvotes: 1

Views: 58

Answers (2)

Adam Comerford
Adam Comerford

Reputation: 21692

The local database contains the oplog, and I'll leave you to research yourself as to what size this should be for a given node. To address the question at hand, from the docs:

For 64-bit Linux, Solaris, FreeBSD, and Windows systems, MongoDB allocates 5% of the available free disk space, but will always allocate at least 1 gigabyte and never more than 50 gigabytes.

That's where your usage is coming from - to alter that allocation you will either need to resize the oplog or, if starting from scratch, look at the oplogSizeMB option (or for the CLI equivalent see here).

Upvotes: 3

DBC
DBC

Reputation: 41

In addition to what Adam said, add the

--oplogSize X

to your parameters and replace X with the amount of MB you want the oplog to be.

Upvotes: 1

Related Questions