Categories: MongoDBNoSQL

MongoDB – How to Add Arbiter to Replica Set

This blog represents the instructions on how to add arbiter to existing Mongodb replica set. Arbiters are MongoDB instances whose primary role is to participate in replica set election in order to break ties and select PRIMARY.This instance do not hold any data and have minimal resource requirements. As a matter of fact, it does not need or require a dedicated hardware to run. However, it is advised to run arbiter on different server than the replica set. It can be any other server such as application server or monitoring server. Further details can be found on this page.

Configure Arbiter Data Storage

An arbiter does not store data. However, that does not prevent Mongod instance start with a set of data files and a full-fledged journal. In order to minimze the default creation of data, the following configuration needs to be set in MongoDB configuration file, /etc/mongod.conf. For WiredTiger storage engine, open the configuration file, /etc/mongod.conf and set the value of storage.journal.enabled as false. The following represents the required change in the conf file.

storage
  dbPath: /path/to/mongo/data/directory
  journal:
    enabled: false

For MMAPv1 storage engine, this is how the configuration would look like:

storage
  dbPath: /path/to/mongo/data/directory
  mmapv1:
    smallFiles: true

Create a Custom Data Directory for Arbiter

In order to have Arbiter store their data files, a separate data directory is recommended. Create a data directory such as /data/arb.

Start Arbiter Instance

Start the mongo instance with custom data directory and –replSet option passing the value of replica set with which the current replicaset is running.

sudo mongod --dbpath /path/to/mongo/arb/data/directory --replSet vflux01

Add Arbiter to ReplicaSet

Login to Primary MongoDB server. Add the Arbiter MongoDB server to the replicaset using following command:

rs.addArb("ip.address.mongodb:27017");

Here is the page describing the rs.addArb command to add arbiter to the existing replicaset.

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.

Share
Published by
Ajitesh Kumar
Tags: mongodbnosql

Recent Posts

Agentic Reasoning Design Patterns in AI: Examples

In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…

2 months ago

LLMs for Adaptive Learning & Personalized Education

Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…

2 months ago

Sparse Mixture of Experts (MoE) Models: Examples

With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…

3 months ago

Anxiety Disorder Detection & Machine Learning Techniques

Anxiety is a common mental health condition that affects millions of people around the world.…

3 months ago

Confounder Features & Machine Learning Models: Examples

In machine learning, confounder features or variables can significantly affect the accuracy and validity of…

3 months ago

Credit Card Fraud Detection & Machine Learning

Last updated: 26 Sept, 2024 Credit card fraud detection is a major concern for credit…

3 months ago