In addition to accepting Command Line Parameters, MongoDB can also be configured using a configuration file. A configuration file to use can be specified using the -f or --config command line options. On some packaged installs of MongoDB (for example Ubuntu & Debian) the default file can be found in /etc/mongodb.conf which is automatically used when starting and stopping MongoDB from the service.
The following example configuration file demonstrates the syntax to use:
# This is an example config file for MongoDB.
dbpath = /var/lib/mongodb
bind_ip = 127.0.0.1
noauth = true # use 'true' for options that don't take an argument
verbose = true # to disable, comment out.
|
Unfortunately flag parameters like "quiet" will register as true no matter what value you put after them. So don't write this: "quiet=false", just comment it out, or remove the line. |
Parameters
Basic database configuration
Parameter | Meaning | Example |
dbpath |
Location of the database files |
dbpath=/var/lib/mongodb |
port |
Port the mongod will listen on |
port=27017 |
bind_ip
|
Specific IP address that mongod will listen on
|
bind_ip=127.0.0.1
|
logpath |
Full filename path to where log messages will be written |
logpath=/var/log/mongodb/mongodb.log |
logappend |
Whether the log file will be appended (TRUE) or over-written (FALSE) |
logappend=true |
Logging
Parameter | Meaning | Example |
cpu |
Enable periodic logging (TRUE) of CPU utilization and I/O wait |
cpu = true |
verbose |
Verbose logging output |
verbose=true |
Security
Parameter | Meaning | Example |
noauth |
Turn authorization on/off. Off is currently the default |
noauth = true |
auth |
Turn authorization on/off. Off is currently the default |
auth=false |
Administration & Monitoring
Parameter | Meaning | Example |
nohttpinterface |
Disable the HTTP interface. The default port is 1000 more than the dbport |
nohttpinterface = true |
noscripting |
Turns off server-side scripting. This will result in greatly limited functionality |
noscripting = true |
notablescan |
Turns off table scans. Any query that would do a table scan fails. |
notablescan = true |
noprealloc |
Disable data file preallocation. |
noprealloc = true |
nssize |
Specify .ns file size for new databases in MB |
nssize = 16 |
mms-token |
Account token for Mongo monitoring server. |
mms-token=mytoken |
mms-name |
Server name for Mongo monitoring server. |
mms-name=monitor.example.com |
mms-interval |
Ping interval for Mongo monitoring server in seconds. |
mms-interval=15
|
quota |
Enable quota management |
quota = true |
quotaFiles |
Determines the number of files per Database (default is 8) |
quotaFiles=16 |
Replication
Parameter | Meaning | Example |
master |
In replicated mongo databases, specify here whether this is a slave or master |
master = true |
slave |
In replicated mongo databases, specify here whether this is a slave or master |
slave = true |
source |
Specify the |
source = master.example.com |
only |
Slave only: specify a single database to replicate |
only = master.example.com |
pairwith |
Address of a server to pair with. |
pairwith = master.example.com:27017 |
arbiter |
Address of arbiter server |
arbiter = aribiter.example.com:27018 |
autoresync |
Automatically resync if slave data is stale |
autoresync |
opIdMem |
Size limit for in-memory storage of op ids in Bytes |
opIdMem=1000 |
fastsync |
Indicate that this instance is starting from a dbpath snapshot of the repl peer |
|
Replica Sets
Parameter | Meaning | Example |
replSet |
Use replica sets with the specified logical set name. Typically the optional seed host list need not be specified. |
replSet=<setname>[/<seedlist>] |
oplogSize |
Custom size for replication operation log in MB. |
oplogSize=100 |
Sharding
Parameter | Meaning | Example |
shardsvr |
Indicates that this mongod will participate in sharding *Optional and just changes the default port |
shardsvr=true |