Database Reference
In-Depth Information
It's obvious that according to the situation, secondaries can become primaries. For in-
stance, if
mongod2.replicaset.com
receives the majority of the votes, it will be-
come the primary in place of
mongod1.replicaset.com
.
The next step will be preparing the configuration file. There are two ways to define the
configuration for MongoDB via a shell or by creating a configuration file. To run
mon-
god
in a production environment, you must define the configurations in a file and set the
filepath to
mongod
in shell. To start
mongod
or
mongos
with a configuration file, the
following commands can be used:
mongod --config /etc/mongodb.conf
mongod -f /etc/mongodb.conf
mongos --config /srv/mongodb/mongos.conf
mongos -f /srv/mongodb/mongos.conf