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

  1. 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 any mongod 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 any mongod instance to run on that host server.
    • A mongos.conf file for every query router (mongos) to run on that host server.
  2. 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.
  3. (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.
  4. 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 the sharding.clusterRole setting in the configuration file (depending on whether it is a config server or a shard server instance).
  5. (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 one mongod 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.
  6. (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.
  7. (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 the replication.replSetName entry. The following table shows how the clusterRole and replSetName 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
  8. (Sharded deployments only) For all your mongos routing processes, set the value of the sharding.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 the sharding.configDB setting would look like this:
    sharding:
        configDB: MtxConfigReplSet/192.168.1.1,192.168.1.2,192.168.1.3
  9. Start up all the mongod instances on each of the MongoDB host servers.
    sudo service mongod start
    (Sharded deployments only) Do not start mongos instances at this time.

What to do next

After you set configuration options for MongoDB instances and start all 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.