Set Configuration Options for MongDB Instances
Set configuration options for MongoDB instances in your non-sharded or sharded MongoDB deployment. This section offers an abbreviated quick start guide for configuring settings in MongoDB configuration files when setting up your Event Repository. For complete information about MongoDB runtime database configuration, refer to the MongoDB documentation.
About this task
You modify values in the mongod.conf
file on your system to control the configuration of your MongoDB database instances (mongod). For a sharded MongoDB deployment, you also
modify values in the mongos.conf
file to control the configuration of your MongoDB routing processes (mongos). Configure each MongoDB instance using its own copy of a
configuration file.
Configuration file templates for regular (non-sharded) database
instances and shards (mongod
), config servers
(mongod
), and query routers (mongos
), are
provided in the discussion about MongoDB configuration file template. You can
replace the content of the default MongoDB configuration files on your
installation with the content of the corresponding template and then modify the
values according to these guidelines.
Procedure
-
On each host server, create and edit a MongoDB configuration file
for each MongoDB process that is to run on that host server. You can replace
the content of the default MongoDB configuration file
/etc/mongod.conf with the content shown in the
MongoDB configuration file templates.
For a non-sharded deployment, you would create and edit:
- A
mongod.conf
file for anymongod
instance (primary or secondaries) that is to run on that host server.
For a sharded deployment, you would create and edit:
- A
mongod.conf
file for anymongod
instance to run on that host server. - A
mongos.conf
file for every query router (mongos
) to run on that host server.
- A
-
Replace the content of the default MongoDB configuration file
/etc/mongod.conf with the content of the corresponding
template:
- If the
mongod
instance is to be a MongoDB server for a non-sharded deployment or a shard server for a sharded deployment, use the content of the "mongod.conf File" template in the discussion about MongoDB configuration file templates. - If the
mongod
instance is to be a config server for a sharded deployment, use the content of the "mongod.conf File for Config Servers (Sharded Clusters)" template in the discussion about MongoDB configuration file templates.
- If the
-
(Sharded deployments only) On all the MongoDB host servers, where a
mongos
is to run (typically, application servers), use the content of the "mongos.conf File (Sharded Clusters)" template in the discussion about MongoDB configuration file templates. -
In each configuration file to be used by each MongoDB instance in
your deployment:
- Enter the appropriate
value for the
bindIp
setting. - Enter the appropriate value for the
security.keyFile
entry.For all MongoDB instances, if authorization is enabled, the value of
security.keyFile
must point to an identical copy of the key file. - Ensure that the values of all other entries are correct for your deployment.
- For sharded clusters, ensure that the role of the
mongod
is specified correctly in thesharding.clusterRole
setting in the configuration file (depending on whether it is a config server or a shard server instance).
- Enter the appropriate
value for the
-
(Sharded deployments only) In the configuration file to be used by
each shard server (
mongod
) in your deployment:- Uncomment the
sharding.clusterRole: shardsvr
setting.The
shardsvr
role changes the default port to 27018. - Only if needed,
uncomment and change the value of the
port
setting.Typically, the default port value for shard server instances (27018) is suitable on a deployment where only onemongod
instance is running on each host server, but it is possible to use another port number.Note: Running multiple shard server instances on the same host server is not a valid configuration for deployment. If you do this for a design or test system, ensure that the port value is unique for each instance.
- Uncomment the
-
(Sharded deployments only) In the configuration file to be used by
each config server (
mongod
) in your deployment:- Only if needed, change
the value of the
port
setting.Typically, the default port value for config servers (27019) is suitable given that three config server instances are typically deployed on different host servers, but it is possible to use another port number if needed.
- Run each instance as a data-bearing node (not as an arbiter).
- Run each instance without replication delay.
- Only if needed, change
the value of the
-
(Sharded deployments only) Verify that the replica-set names and cluster roles
are accurately set for each MongoDB instance in your sharded cluster.
Every
mongod
instance is a member of one of the replica sets, and each replica set must have a unique name, specified using thereplication.replSetName
entry. The following table shows how theclusterRole
andreplSetName
of each MongoDB instance can be assigned for a sharded deployment with two shards.MongoDB Instance Host Server Default Port Number
replication. replSetName sharding. clusterRole Config Server Server1 (192.168.1.1) 27019 MtxConfigReplSet configsvr Config Server Server2 (192.168.1.2) 27019 MtxConfigReplSet configsvr Config Server Server3 (192.168.1.3) 27019 MtxConfigReplSet configsvr Shard Server for Shard 1 Server4 (192.168.1.4) 27018 MtxShard1ReplSet shardsvr Shard Server for Shard 1 Server5 (192.168.1.5) 27018 MtxShard1ReplSet shardsvr Shard Server for Shard 1 Server6 (192.168.1.6) 27018 MtxShard1ReplSet shardsvr Shard Server for Shard 2 Server7 (192.168.1.7) 27018 MtxShard2ReplSet shardsvr Shard Server for Shard 2 Server8 (192.168.1.8) 27018 MtxShard2ReplSet shardsvr Shard Server for Shard 2 Server9 (192.168.1.9) 27018 MtxShard2ReplSet shardsvr -
(Sharded deployments only) For all your
mongos
routing processes, set the value of thesharding.configDB
setting to point to the configuration servers. For example, if three configuration servers are to bind to the IP addresses 192.168.1.1, 192.168.1.2, and 192.168.1.3, then thesharding.configDB
setting would look like this:sharding: configDB: MtxConfigReplSet/192.168.1.1,192.168.1.2,192.168.1.3
-
Start up all the
mongod
instances on each of the MongoDB host servers.sudo service mongod start(Sharded deployments only) Do not startmongos
instances at this time.
What to do next
mongod
instances, the next steps are:
- (For non-sharded deployments only) Initiate the replica set of your deployment.
- (For sharded deployments only) Initiate the shard replica sets and the config server replica set of your deployment.