Database Replica Set Administration
Contents
Introduction
This is the guide for the first time configuration of a MongoDB Replica Set following installation.
Prerequisites
Installation of MongoDB on a primary, secondary, and arbiter (PSA) system or on a primary and two secondaries. During installation the replica database options must have been selected for each server. See Installing the Software for more information.
Robo3T or Studio 3T installed on the primary database system or a system that has network access to the primary database server.
Given the reduced resilience and potential performance issues associated with the PSA architecture when in a failure state, it is strongly recommended that database resilience is implemented with a minimum of 3 full database servers. The arbiter should be avoided if possible.
Create the Replica Set
When the database servers are installed in Replica Set mode they are configured for replication but without any information about the other member servers. This needs to be provided using the MongoDB replica set Initialise command. The command can be used to configure all member details in a single step. Use the command to apply the required settings for your architecture.
Primary, Secondary and Arbiter (PSA)
The example below configures a PSA architecture. You need to adjust the IP addresses and ports in the member list to match your setup.
rs.initiate({_id:'ClearWay', members:[
{_id:0,host:'10.127.1.62:27010'},
{_id:1,host:'10.127.1.63:27010'},
{_id:2,host:'10.127.1.64:27010', arbiterOnly:true}
]})
The initial _id field is the replica set name. This defaults to either ClearWay or AdvanceGuard depending on the product you are using.
The members list contains an entry for each server. Each entry must include a numeric id, IP address and port. Ensure you enter your own server details.
Set the arbiterOnly attribute to true on the last server.
Primary and Two Secondaries
The example below configures a three server architecture. You need to adjust the IP addresses and ports in the member list to match your setup. Note that the only difference is the use of the arbiterOnly option.
rs.initiate({_id:'ClearWay', members:[
{_id:0,host:'10.127.1.62:27010'},
{_id:1,host:'10.127.1.63:27010'},
{_id:2,host:'10.127.1.64:27010'}
]})
The initial _id field is the replica set name. This defaults to either ClearWay or AdvanceGuard depending on the product you are using.
The members list contains an entry for each server. Each entry must include a numeric id, IP address and port. Ensure you enter your own server details.
You can use host names in place of IP addresses but only if the servers are part of a network that has full DNS support. If you are unsure about the DNS setup then use IP addresses.
Execute Commands using Robo3T
Start Robo3T.
Select Create, and enter the connection information of the primary database. By default, the database is configured to use port 27010.