Install and configure MongoDB for EMG

EMG can use MongoDB as the data store for queues, delivery report etc in an active-active configuration.

MongoDB needs to be installed on 3 nodes to function properly.

In this article we will install MongoDB 2.6.4 (Linux 64-bit) on three Linux servers with ip addresses, and

Installation will be done under directory /opt giving the installation directory /opt/mongodb-linux-x86_64-2.6.4.

The data files will be placed in /opt/mongodb-data. All paths etc can of course be adjusted if needed in your environment.

We assume EMG has already been installed in directory “/home/emg” and configured to be run by user “emg”.

Installing MongoDB

  • Login as root on first node ( in this example), download and extract MongoDB.
    cd /opt
    curl -OL ""
    tar xvzf mongodb-linux-x86_64-2.6.4.tgz
    mkdir mongodb-data
    chown -R emg.emg mongodb-data mongodb-linux-x86_64-2.6.4
  • Now switch to user “emg” and create a script to start up mongo (or we actually provide one for your convenience.
    su - emg
    cd /opt/mongodb-linux-x86_64-2.6.4
    curl -OL
    chmod 700
  • Review the “” script to ensure it matches your environment and then run it to start mongod
  • Repeat the process on the other two nodes ( and

Checking mongod status

In /opt/mongodb-data/server.log on each node you can see the mongod server log. Until all three nodes are up and running there will be messages similar to this one:

replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)

When mongod has been started on all three nodes the messages will change to something like this:

[conn41] end connection (1 connection now open)
[initandlisten] connection accepted from #43 (2 connections now open)

This indicates that all is ok.

EMG configuration

To make EMG use MongoDB as data store add the following to the EMG server.cfg (a suitable place may be just before first connector configuration):


DB mongo <
# 1 - Acknowledge when primary node has applied transaction
# 2 - Acknowledge when primary and one secondary node have applied transaction

Make this change on all three nodes and you should then be able to start emgd.

If you place a message in queue on a connector all of the nodes will see it and any of the nodes can pick it up and deliver it.

Managing MongoDB

It is possible to get information from MongoDB and manage a running instance using the mongo shell instance to run javascript commands.

Sample session checking if local MongoDB instance is the master in the replica set:

cd /opt/mongodb-linux-x86_64-2.6.4
bin/mongo --quiet --host --port 17037
emg:SECONDARY> print("ismaster=" + rs.isMaster().ismaster);
emg:SECONDARY> exit

More information: