Windows MongoDB Arbiter

Jan 2020

Introduction

MongoDB is a software component of the MediaKind Controller. It is the database that is used to store configurations etc. Controller is normally deployed on multiple nodes to provide High Availability and Redundancy. In this case, MongoDB uses a replica set.
A replica set is a group of mongod instances that maintain the same data set. A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes. An extra mongod instance may be added to a replica set as an arbiter. The purpose of an arbiter is to maintain a quorum in a replica set by responding to heartbeat and election requests by other replica set members.

Download MongoDB

Firstly we need to download MongoDB, this can be downloaded from https://www.mongodb.com/download-center/community?jmp=docs
At the time of writing, we are using v3.6 which you can also get here.

Install MongoDB

• Double-click the .MSI file and click Next
• Accept the terms of the license agreement and click Next
• Choose Complete Installation
• Uncheck “Install MongoDB Compass” and click Next
• Click Install
• Click Finish to exit the Setup Wizard
MongoDB will be installed in C:\Program Files\MongoDB\Server\3.6

Configure MongoDB

Create a folder structure to contain the database files and logs. The MongoDB documentation uses C:\data but a more obvious name is C:\mongo

cd C:\
mkdir "\mongo\db" "\mongo\log"

Create a MongoDB configuration file “C:\Program Files\MongoDB\Server\3.6\mongod.cfg”

systemLog:
destination: "file"
path: "c:\\mongo\\log\\mongod.log"
storage:
dbPath: "c:\\mongo\\db"
replication:
replSetName: repldb
security:
authorization: enabled
keyFile: "c:\\Program Files\\MongoDB\\Server\\3.6\\mongodb.key"
transitionToAuth: false
net:
port: 27018
bindIp: 0.0.0.0

You can download the mongod.cfg file here:
Create a MongoDB key file:
Create the file “C:\Program Files\MongoDB\Server\3.6\mongodb.key”
The contents of the key file should be the same as the corresponding file on the Controller instances. This can be found using the following CentOS command:

cat /etc/ericsson/secrets/mongo/mongodb.key

Just copy the mongodb.key file from your Controller to your Windows MongoDB folder (C:\Program Files\MongoDB\Server\3.6)