This documentation supports the 18.02 version of BMC Digital Workplace. To view the latest version, select the version from the Product version menu.

Configuring MongoDB for replica set

The examples in this procedure use the following configuration: 

  • MongoDB1 server with the IP address 10.20.30.40 (Primary)
  • MongoDB2 server with the IP address 10.20.30.41 (Secondary)
  • MongoDB3 server with the IP address 10.20.30.42 (Secondary)

Before you begin

Install MongoDB on each server, as described in Installing and setting up MongoDB on Windows or Installing and setting up MongoDB on Linux.

Note

For a functional replica set, you must have at least two out of three instances active. 

To configure MongoDB as a replica set

  1. Copy the key file, which you created while installing and setting up MongoDB on the primary server, to the secondary servers.
    The keyFile parameter from the mongod.conf file specifies the location at which the key file should be placed. For example, keyFile = /dbdata/mongodb/mongo.key. Ensure that the key file is placed at the specified location on the secondary servers.

  2. Ensure that the user running the mongod instances on each server can access the key file.

  3. Verify that MongoDB is running on all the servers:

    Go to services.msc and search for the mongo instances in Windows.

    Use the ps -aef | grep "mongo" command in Linux.

  4. Start the mongo shell on the primary server.
    Example: c:\dbdata\mongodb\mongodb-win32-x86_64-2008plus-x.y.z\bin\mongo.exe
  5. Issue the following commands:

    > use admin 
    > db.auth("siteRootAdmin", "<yourPassword>"); 
    1
    > rs.initiate() 
    { 
       "info2" : "no configuration explicitly specified -- making one", 
       "me" : "10.20.30.40:27017", 
       "info" : "Config now saved locally. Should come online in about a minute.", 
       "ok" : 1 
    }
  6. After a few minutes, verify in the same window with the rs.conf()  command:

    > rs.conf() 
    { 
       "_id" : "myitsocial", 
       "version" : 1, 
       "members" : [ 
           { 
              "_id" : 0, 
              "host" : "10.20.30.40:27017" 
           } 
       ] 
    }
  7. From the mongo shell on the primary server, add secondaries:

    >rs.add("10.20.30.41:27017") 
    >rs.add("10.20.30.42:27017")
  8. To check the status of the replica set, run the rs.status()  command.
     You should see output similar to the following example:

    { 
    "set" : "myitsocial", 
    "date" : ISODate("2014-08-12T06:15:02Z"), 
    "myState" : 1, 
    "members" : [ 
       { 
          "_id" : 0, 
          "name" : "10.20.30.40:27017", 
          "health" : 1, 
          "state" : 1, 
          "stateStr" : "PRIMARY", 
          "uptime" : 303165, 
          "optime" : Timestamp(1407521114, 1), 
          "optimeDate" : ISODate("2014-08-08T18:05:14Z"), 
          "self" : true 
       }, 
       { 
          "_id" : 1, 
          "name" : "10.20.30.41:27017", 
          "health" : 1, 
          "state" : 2, 
          "stateStr" : "SECONDARY", 
          "uptime" : 302985, 
          "optime" : Timestamp(1407521114, 1), 
          "optimeDate" : ISODate("2014-08-08T18:05:14Z"), 
          "lastHeartbeat" : ISODate("2014-08-12T06:15:02Z"), 
          "lastHeartbeatRecv" : ISODate("2014-08-12T06:15:02Z"), 
          "pingMs" : 0, 
       "syncingTo" : "10.20.30.40:27017" 
       },
       { 
          "_id" : 2, 
          "name" : "10.20.30.42:27017", 
          "health" : 1, "state" : 2, 
          "stateStr" : "SECONDARY", 
          "uptime" : 302985, 
          "optime" : Timestamp(1407521114, 1), 
          "optimeDate" : ISODate("2014-08-08T18:05:14Z"), 
          "lastHeartbeat" : ISODate("2014-08-12T06:15:02Z"), 
          "lastHeartbeatRecv" : ISODate("2014-08-12T06:15:02Z"), 
          "pingMs" : 0, 
          "syncingTo" : "10.20.30.40:27017" 
       } 
    ], 
    "ok" : 1 
    } 
  9. (Optional) To rotate mongodb logs, run the logRotate command from the admin schema:

    use admin
    db.runCommand( { logRotate : 1} )
  10. (Optional) For Linux, ensure that ulimit is set to 64000:
    ulimit -n 64000
  11. For each BMC Digital Workplace or SmartIT server, verify and change the config.js file in Smart_IT_MyIT/social:

    “db_host”: "mongodb://<mongo1 IP:27017>,<mongo2 IP:27017>,<mongo3 IP:27017>/", 
    "db_name": "social",
    "db_auth":true,   
    "db_username": "social_admin",   
    "db_pw": "<your-password-goes-here>", 

Where to go from here

Applying Mongo DB security settings

Was this page helpful? Yes No Submitting... Thank you

Comments