mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data format, and performs background management operations.
This document provides a complete overview of all command line options for mongod. These options are primarily useful for testing purposes. In common operation, use the configuration file options to control the behavior of your database, which is fully capable of all operations described below.
- --help, -h¶
Returns a basic help and usage text.
Returns the version of the mongod daemon.
- --config <filename>, -f <filename>¶
Specifies a configuration file, that you can use to specify runtime-configurations. While the options are equivalent and accessible via the other command line arguments, the configuration file is the preferred method for runtime configuration of mongod. See the “Configuration File Options” document for more information about these options.
- --verbose, -v¶
Increases the amount of internal reporting returned on standard output or in the log file specified by --logpath. Use the -v form to control the level of verbosity by including the option multiple times, (e.g. -vvvvv.)
Runs the mongod instance in a quiet mode that attempts to limit the amount of output. This option suppresses:
- --port <port>¶
Specifies a TCP port for the mongod to listen for client connections. By default mongod listens for connections on port 27017.
UNIX-like systems require root privileges to use ports with numbers lower than 1024.
- --bind_ip <ip address>¶
The IP address that the mongod process will bind to and listen for connections. By default mongod listens for connections all interfaces. You may attach mongod to any interface; however, when attaching mongod to a publicly accessible interface ensure that you have implemented proper authentication and/or firewall restrictions to protect the integrity of your database.
- --maxConns <number>¶
Specifies the maximum number of simultaneous connections that mongod will accept. This setting will have no effect if it is higher than your operating system’s configured maximum connection tracking threshold.
You cannot set maxConns to a value higher than 20000.
Forces the mongod to validate all requests from clients upon receipt to ensure that invalid objects are never inserted into the database. Enabling this option will produce some performance impact, and is not enabled by default.
- --logpath <path>¶
Specify a path for the log file that will hold all diagnostic logging information.
Unless specified, mongod will output all log information to the standard output. Additionally, unless you also specify --logappend, the logfile will be overwritten when the process restarts.
The behavior of the logging system may change in the near future in response to the SERVER-4499 case.
When specified, this option ensures that mongod appends new entries to the end of the logfile rather than overwriting the content of the log when the process restarts.
New in version 2.1.0.
- --pidfilepath <path>¶
Specify a file location to hold the “PID” or process ID of the mongod process. Useful for tracking the mongod process in combination with the mongod --fork option.
- --keyFile <file>¶
Specify the path to a key file to store authentication information. This option is only useful for the connection between replica set members.
- --unixSocketPrefix <path>¶
Specifies a path for the UNIX socket. Unless this option has a value mongod creates a socket with /tmp as a prefix.
Enables a daemon mode for mongod that runs the process to the background. This is the normal mode of operation, in production and production-like environments, but may not be desirable for testing.
Enables database authentication for users connecting from remote hosts. Configure users via the mongo shell. If no users exist, the localhost interface will continue to have access to the database until the you create the first user.
See the Security and Authentication page for more information regarding this functionality.
Forces mongod to report the percentage of CPU time in write lock. mongod generates output every four seconds. MongoDB writes this data to standard output or the logfile if using the logpath option.
- --dbpath <path>¶
Specify a directory for the mongod instance to store its data. Typical locations include: /srv/mongodb, /var/lib/mongodb or /opt/mongodb
Unless specified, mongod will look for data files in the default /data/db directory. (Windows systems use the \data\db directory.) If you installed using a package management system. Check the /etc/mongodb.conf file provided by your packages to see the configuration of the dbpath.
- --diaglog <value>¶
Creates a very verbose, diagnostic log for troubleshooting and recording various errors. MongoDB writes these log files in the dbpath directory in a series of files that begin with the string diaglog and end with the initiation time of the logging as a hex string.
The specified value configures the level of verbosity. Possible values, and their impact are as follows.
Value Setting 0 off. No logging. 1 Log write operations. 2 Log read operations. 3 Log both read and write operations. 7 Log write and some read operations.
You can use the mongosniff tool to replay this output for investigation. Given a typical diaglog file, located at /data/db/diaglog.4f76a58c, you might use a command in the following form to read these files:
mongosniff --source DIAGLOG /data/db/diaglog.4f76a58c
--diaglog is for internal use and not intended for most users.
Setting the diagnostic level to 0 will cause mongod to stop writing data to the diagnostic log file. However, the mongod instance will continue to keep the file open, even if it is no longer writing data to the file. If you want to rename, move, or delete the diagnostic log you must cleanly shut down the mongod instance before doing so.
Alters the storage pattern of the data directory to store each database’s files in a distinct folder. This option will create directories within the --dbpath named for each directory.
Use this option in conjunction with your file system and device configuration so that MongoDB will store data on a number of distinct disk devices to increase write throughput or disk capacity.
If you have an existing mongod instance and dbpath, and you want to enable --directoryperdb, you must migrate your existing databases to directories before setting --directoryperdb to access those databases.
Given a dbpath directory with the following items:
journal mongod.lock local.0 local.1 local.ns test.0 test.1 test.ns
journal mongod.lock local/local.0 local/local.1 local/local.ns test/test.0 test/test.1 test/test.ns
Enables operation journaling to ensure write durability and data consistency. mongod enables journaling by default on 64-bit builds of versions after 2.0.
- --journalOptions <arguments>¶
Provides functionality for testing. Not for general use, and may affect database integrity.
- --journalCommitInterval <value>¶
Specifies the maximum amount of time for mongod to allow between journal operations. Possible values are between 2 and 300 milliseconds. Lower values increase the durability of the journal, at the expense of disk performance.
The default journal commit interval is 100 milliseconds if a single block device (e.g. physical volume, RAID device, or LVM volume) contains both the journal and the data files.
If the journal and data files are on file systems associated with different block devices the default journal commit interval is 30 milliseconds.
To force mongod to commit to the journal more frequently, you can specify j:true. When a write operation with j:true is pending, mongod will reduce journalCommitInterval to a third of the set value.
Specify this option to enable IPv6 support. This will allow clients to connect to mongod using IPv6 networks. mongod disables IPv6 support by default in mongod and all utilities.
Permits JSONP access via an HTTP interface. Consider the security implications of allowing this activity before enabling this option.
Disable authentication. Currently the default. Exists for future compatibility and clarity.
Disables the HTTP interface.
Disables the durability journaling. By default, mongod enables journaling in 64-bit versions after v2.0.
Disables the preallocation of data files. This will shorten the start up time in some cases, but can cause significant performance penalties during normal operations.
Disables the scripting engine.
Forbids operations that require a table scan.
- --nssize <value>¶
Specifies the default size for namespace files (i.e .ns). This option has no impact on the size of existing namespace files. The maximum size is 2047 megabytes.
The default value is 16 megabytes; this provides for approximately 24,000 namespaces. Each collection, as well as each index, counts as a namespace.
- --profile <level>¶
Changes the level of database profiling, which inserts information about operation performance into output of mongod or the log file. The following levels are available:
Level Setting 0 Off. No profiling. 1 On. Only includes slow operations. 2 On. Includes all operations.
Profiling is off by default. Database profiling can impact database performance. Enable this option only after careful consideration.
- --quotaFiles <number>¶
Runs a repair routine on all databases. This is equivalent to shutting down and running the repairDatabase database command on all databases.
In general, if you have an intact copy of your data, such as would exist on a very recent backup or an intact member of a replica set, do not use repairDatabase or related options like db.repairDatabase() in the mongo shell or mongod --repair. Restore from an intact copy of your data.
Changed in version 2.1.2.
If you run the repair option and have data in a journal file, mongod will refuse to start. In these cases you should start mongod without the --repair option to allow mongod to recover data from the journal. This will complete more quickly and will result in a more consistent and complete data set.
To continue the repair operation despite the journal files, shut down mongod cleanly and restart with the --repair option.
--repair copies data from the source data files into new data files in the repairpath, and then replaces the original data files with the repaired data files. If repairpath is on the same device as dbpath, you may interrupt a mongod running --repair without affecting the integrity of the data set.
- --repairpath <path>¶
- --slowms <value>¶
Defines the value of “slow,” for the --profile option. The database logs all slow queries to the log, even when the profiler is not turned on. When the database profiler is on, mongod the profiler writes to the system.profile collection. See the profile command for more information on the database profiler.
Enables a mode where MongoDB uses a smaller default file size. Specifically, --smallfiles reduces the initial size for data files and limits them to 512 megabytes. --smallfiles also reduces the size of each journal files from 1 gigabyte to 128 megabytes.
Use --smallfiles if you have a large number of databases that each holds a small quantity of data. --smallfiles can lead your mongod to create a large number of files, which may affect performance for larger databases.
Used in control scripts, the --shutdown will cleanly and safely terminate the mongod process. When invoking mongod with this option you must set the --dbpath option either directly or by way of the configuration file and the --config option.
--shutdown is only available on Linux systems.
- --syncdelay <value>¶
mongod writes data very quickly to the journal, and lazily to the data files. --syncdelay controls how much time can pass before MongoDB flushes data to the database files via an fsync operation. The default setting is 60 seconds. In almost every situation you should not set this value and use the default setting.
If you set --syncdelay to 0, MongoDB will not sync the memory mapped files to disk. Do not set this value on production systems.
Returns diagnostic system information and then exits. The information provides the page size, the number of physical pages, and the number of available physical pages.
Upgrades the on-disk data format of the files specified by the --dbpath to the latest version, if needed.
This option only affects the operation of mongod if the data files are in an old format.
In most cases you should not set this value, so you can exercise the most control over your upgrade process. See the MongoDB release notes (on the download page) for more information about the upgrade process.
For internal diagnostic use only.
- --replSet <setname>¶
Use this option to configure replication with replica sets. Specify a setname as an argument to this set. All hosts must have the same set name.
- --oplogSize <value>¶
Specifies a maximum size in megabytes for the replication operation log (e.g. oplog.) By mongod creates an oplog based on the maximum amount of space available. For 64-bit systems, the op log is typically 5% of available disk space.
Once the mongod has created the oplog for the first time, changing --oplogSize will not affect the size of the oplog.
In the context of replica set replication, set this option if you have seeded this member with a snapshot of the dbpath of another member of the set. Otherwise the mongod will attempt to perform an initial sync, as though the member were a new member.
If the data is not perfectly synchronized and mongod starts with fastsync, then the secondary or slave will be permanently out of sync with the primary, which may cause significant consistency problems.
New in version 2.2.
By default secondary members of a replica set will load all indexes related to an operation into memory before applying operations from the oplog. You can modify this behavior so that the secondaries will only load the _id index. Specify _id_only or none to prevent the mongod from loading any index into memory.
These options provide access to conventional master-slave database replication. While this functionality remains accessible in MongoDB, replica sets are the preferred configuration for database replication.
- --source <host><:port>¶
For use with the --slave option, the --source option designates the server that this instance will replicate.
- --only <arg>¶
- --slavedelay <value>¶
For use with the --slave option. When set, --autoresync option allows this slave to automatically resync if it is more than 10 seconds behind the master. This setting may be problematic if the --oplogSize specifies a too small oplog. If the oplog is not large enough to store the difference in changes between the master’s current state and the state of the slave, this instance will forcibly resync itself unnecessarily. When you set the autoresync option to false, the slave will not attempt an automatic resync more than once in a ten minute period.