Command Line Parameters

MongoDB can be configured via command line parameters in addition to File Based Configuration. You can see the currently supported set of command line options by running the database with -h [ --help ] as a single parameter:

$ ./mongod --help

Information on usage of these parameters can be found in Starting and Stopping Mongo.

The following list of options is not complete; for the complete list see the usage information as described above.

Basic Options

-h | --help Shows all options
-f | --config <file> Specify a configuration file to use
--port <portno> Specifies the port number on which Mongo will listen for client connections. Default is 27017
--dbpath <path> Specifies the directory for datafiles. Default is /data/db or c:\data\db
--fork Fork the server process
--bind_ip <ip> Specifies a single IP that the database server will listen for
--directoryperdb Specify use of an alternative directory structure, in which files for each database are kept in a unique directory. (since 1.3.2)
--quiet Reduces amount of log output
--nohttpinterface Disable the HTTP interface (localhost:27018)
--rest Allow extended operations at the Http Interface
--logpath <file> File to write logs to (instead of stdout). You can rotate the logs by sending SIGUSR1 to the server.
--logappend Append to existing log file, instead of overwritting
--repairpath <path> Root path for temporary files created during database repair. Default is dbpath value.
--cpu Enables periodic logging of CPU utilization and I/O wait
--noauth Turns off security. This is currently the default
--auth Turn on security
-v[v[v[v[v]]]] | --verbose Verbose logging output (-vvvvv is most verbose, -v == --verbose)
--objcheck Inspect all client data for validity on receipt (useful for developing drivers)
--quota Enable db quota management
--diaglog <n> Set oplogging level where n is 0=off (default) 1=W 2=R 3=both 7=W+some reads
--nocursors Diagnostic/debugging option
--nohints Ignore query hints
--noscripting Turns off server-side scripting. This will result in greatly limited functionality
--notablescan Turns off table scans. Any query that would do a table scan fails
--noprealloc Disable data file preallocation
--smallfiles Use a smaller default file size
--nssize <MB> Specifies .ns file size for new databases
--sysinfo Print system info as detected by Mongo and exit
--upgrade Upgrade database files to new format if necessary
(required when upgrading from <= 1.0 to 1.1+)

Master/Slave Replication Options

--master Designate this server as a master in a master-slave setup
--slave Designate this server as a slave in a master-slave setup
--source <server:port> Specify the source (master) for a slave instance
--only <db> Slave only: specify a single database to replicate
--arbiter <server:port> Address of arbiter server
--autoresync Automatically resync if slave data is stale
--oplogSize <MB> Custom size for replication operation log

Replica Set Options

--replSet <setname> Use replica sets with the specified logical set name
--oplogSize <MB> Custom size for replication operation log


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus