When you install Sisense, a MongoDB instance is installed locally on your machine that contains metadata for ElastiCubes, dashboards, and users. The goal of the replica set is to ensure that each MongoDB has the same information about ElastiCubes, dashboards, and filters. If a MongoDB fails on one query server, the next available MongoDB can replace it. To maintain consistency throughout your configuration and support high availability, each MongoDB instance must be identical with the other MongoDB instances in your configuration.

Each MongoDB instance is part of a replica set. A replica set is a group of MongoDB instances that have the same Sisense data. There are two types of nodes within a replica set. The primary node, which supports write operations and the secondary nodes, which replicate the primary MongoDB’s operations log and syncs the data to reflect that of the primary MongoDB.

The primary and secondary MongoDB nodes can be hosted on the build or query nodes in a high availability configuration or on their own servers.

There are four steps to support high availability for the MongoDB in Sisense:

  1. Preparing to set up replica set.
  2. Setting up replica nodes.
  3. Creating a replica set.
  4. Connecting Sisense to the replica set.

Prerequisites

  1. Servers in which port 27018 is open.
  2. RoboMongo installed on a machine that has access to those servers on port 27018 (any node can be on one of the servers).
  3. MongoDB installed on the machine. By default, this is installed when Sisense is installed. If Sisense is not installed, download MongoDB version 2.4.5 zip on the secondary servers from here.

Preparing to Set up a Replica Set

For each machine that you have installed Sisense, you must stop the Sisense-related services from running to prepare the main MongoDB instance that will be replicated to the other secondary nodes.

This procedure assumes your primary node has Sisense installed.

To prepare each server node in your replica set:

  1. Log in to the machine that hosts Sisense.
  2. Depending on your Sisense installation:
    1. Full IIS: Open the IIS Manager and stop the website SisenseWeb.
    2. IIS Express: Open Windows Services and stop the service Sisense.WebExpress.
  3. In Windows Services, stop the service named Monitoring Agent_service and the service Sisense.Repository.
    repservices
  4. For the server that will be the primary node, backup the Sisense MongoDB instance by copying this directory and saving to another location:
    C:\ProgramData\Sisense\PrismWeb\DB\Prod
    You can delete the backup copy after you have verified that everything is running as expected.
  5. For each secondary server where Sisense is installed, backup the contents of the directory below including the MongoDB instance.
    C:\ProgramData\Sisense\PrismWeb\DB\Prod

Setting Up the Replica Nodes

For each node in your replica set, you must have a MongoDB configuration file. The configuration file contains information about the MongoDB such as its open port and the name of the replica set the MongoDB instance belongs to.

When Sisense is installed on the node, this configuration file is created for you. You must add the line replSet=replica_set to the configuration file. This line is used to identify the node as part of the replica set.

For nodes in which Sisense is not installed, you must create this configuration file as described in the procedure below.

To set up a node:

When Sisense is installed:

  1. In the directory, ‘C:\Program Files\Sisense\Infra\MongoDB\MongoDB.conf’, backup the MongoDB configuration.
  2. In the original MongoDB.conf file, add the line replSet = replica_set.
    dbpath=C:\ProgramData\Sisense\PrismWeb\DB\Prod
    logpath=C:\ProgramData\Sisense\PrismWeb\DB\Logs\sisenseRepository.log
    port=27018
    noauth=true
    smallfiles=true
    replSet=replica_set
  3. In Windows Services, restart the Sisense.Repository service.

When Sisense is not installed:

  1. If Sisense is not installed, MongoDB must be downloaded as described in the Prerequisites. Extract the MongoDB zip to a directory called c:\Sisense.
    After extracting the file you should see an executable mongod file at c:\Sisense\bin\mongod.exe.
  2. In the directory c:\Sisense\bin\, create a file named ‘MongoDB.conf’ as shown below:
    dbpath=C:\Sisense\DB\Prod
    logpath=C:\Sisense\DB\Logs\PrismWeb.log
    port=27018
    noauth=true
    smallfiles=true
    replSet = replica_set
  3. In the directory c:\Sisense\, create the following directories as listed below: DB with two subdirectories named Log and Prod within it.
    mongodir
  4. In the Windows Command Prompt, run the following command to install MongoDB as a Windows service:
    C:\Sisense\bin\mongod.exe --config C:\Sisense\MongoDB.conf --install
  5. In Windows Services, start the MongoDB service.
  6. Verify that the MongoDB service is running and that its startup type is automatic.
    mongodbauto

Creating a Replica Set

After you have prepared the MongoDB configuration file for each of your nodes, you must create a replica set with these nodes. With a replica set, each member has the same Sisense data but is otherwise independent. If the primary becomes unavailable, the replica set holds an election to select a new primary from one of the secondary nodes.

To create replica set:

  1. Open Robomongo and select Open Shell to connect to the primary node.
    roboshell
  2. In the new shell, run the command rs.initiate() to create a replica set.
  3. Run the following commands:
    cfg = rs.conf()
    cfg.members[0].host = "XX.XX.XX.XX:27018" (Enter your IP address of the primary node and the MongoDB port, by default 27018).
    rs.reconfig(cfg)
  4. Run the command rs.add(“XX.XX.XX.XX:27018”), where the XX is the IP address of your secondary node. Run this command to add the unique IP address for each secondary node. For example:
    rs.initiate()
    cfg = rs.conf()
    cfg.members[0].host = "10.50.1.199:27018"
    rs.reconfig(cfg)
    
    rs.add("10.20.1.196:27018")
    rs.add("10.20.1.197:27018")
  5. Run the command rs.status() to verify that the replica set was configured properly. Run this command every couple of minutes to check the progress until stateStr of the secondaries service displays SECONDARY.
    secondary

 

Connecting Sisense to the Replica Set

After you have configured the replica set, you must connect it to Sisense to support your high availability configuration.

Repeat the procedure below for each machine with Sisense installed.

To connect Sisense to a replica set:

  1. In the directory “C:\Program Files\Sisense\PrismWeb\App_Data\Configurations\” backup the file db.config.
  2. In the original db.config file, modify the line:
    <add name="MongoProvider" connectionString="MongoDB://localhost:27018/?safe=true"/>
    To read:
    <add name="MongoProvider" connectionString="MongoDB://XX.XX.X.XX:27018,XX.XX.X.XX:27018,XX.XX.X.XX:27018/?replicaset=replica_set&amp;readPreference=primaryPreferred&amp;safe=true"/></connectionStrings>
    Where XX.XX.XX.XX:27018 is the IP address and port for each MongoDB instance in your replica set separated by a comma.
  3. In this directory “C:\Program Files\Sisense\PrismWeb\vnext\config”, backup the file default.yaml
  4. In the original default.yaml file, at the bottom add the following:
    replica_set:
     name: 'replica_set'
     servers:
     - host: XX.XX.X.XX
       port: 27018
       dbpath: 'C:\ProgramData\Sisense\PrismWeb\DB\Prod'
     - host: XX.XX.X.XX
       port: 27018
       dbpath: 'C:\Sisense\DB\Prod'
     - host: XX.XX.X.XX
       port: 27018
       dbpath: 'C:\Sisense\DB\Prod'
    The dbpath line should be ‘C:\ProgramData\Sisense\PrismWeb\DB\Prod’ on nodes in which Sisense is installed and ‘C:/Sisense/DB/Prod’ when Sisense is not installed.
  5. In Windows Services, start the service Sisense.Repository.
  6. Depending on your Sisense installation,
  1. Full IIS: Open the IIS Manager and start the website SisenseWeb.
  2. IIS Express: Open Windows Services and start the service Sisense.WebExpress.