Database Reference
In-Depth Information
In this example, we use the /etc/mongodb.conf path to store the configuration file.
The following configuration shows our file content:
dbpath = /usr/local/var/mongodb
logpath = /var/log/mongodb.log
bind_ip = 127.0.0.1
port = 27017
fork = true
replSet = rs1
We will review some of the important options briefly. In order to define the path of the
stored data, you should use the dbpath property. Also, the logpath property defines
the path of the logfile. Using the bind_ip command, you can define the network inter-
face that mongod or mongos will listen to. Without defining this property, MongoDB
accepts all connections from all network interfaces. Consequently, you need to configure
the firewall properly to prevent unexpected connections.
The port property defines the port number; the process will listen on this port. It would
be better to leave this property and use the mongod default port, but for educational pur-
poses we will use it and set the port to the mongod default port number, which is 27017 .
Additionally, using the fork property, you can run mongod or mongos as a daemon. To
use this property, you must already define the logpath in the configuration.
The last property is replSet , which is used to define the replica set name.
Note
For more information on properties and options, you can read the documentation at ht-
tp://docs.mongodb.org/manual/reference/configuration-options/ .
After saving the config file, you can run the mongod instances using the --config
parameter.
The following screenshot illustrates the result of executing the mongod command with
the --config parameter:
Search WWH ::




Custom Search