Add an Arbiter to Replica Set

Arbiters are mongod instances that are part of areplica set but do not hold data. Arbiters participate inelections in order to break ties.If a replica set has an even number of members, add an arbiter.

Arbiters have minimal resource requirements and do not requirededicated hardware. You can deploy an arbiter on an applicationserver or a monitoring host.

Important

Do not run an arbiter on systems that also host theprimary or the secondary members of the replica set.

Considerations

Read Concern majority and Three-Member PSA

For 3-Member Primary-Secondary-Arbiter Architecture*

If you have a three-member replica set with aprimary-secondary-arbiter (PSA) architecture or a sharded clusterwith a three-member PSA shards, the cache pressure will increase ifany data bearing node is down and support for"majority" read concern is enabled.

To prevent the storage cache pressure from immobilizing a deploymentwith a three-member primary-secondary-arbiter (PSA) architecture,you can disable read concern “majority” starting in MongoDB 4.0.3(and 3.6.1+). For more information, seeDisable Read Concern Majority.

Replica Set Protocol Version

Note

For the following MongoDB versions, pv1 increases the likelihoodof w:1 rollbacks compared to pv0(no longer supported in MongoDB 4.0+) for replica sets with arbiters:

  • MongoDB 3.4.1
  • MongoDB 3.4.0
  • MongoDB 3.2.11 or earlier

See Replica Set Protocol Version.

Arbiter

An arbiter does not store data, but until the arbiter’s mongodprocess is added to the replica set, the arbiter will act like any othermongod process and start up with a set of data files and with afull-sized journal.

IP Binding

Starting in MongoDB 3.6, MongoDB binaries, mongod andmongos, bind to localhost by default. If thenet.ipv6 configuration file setting or the —ipv6command line option is set for the binary, the binary additionally bindsto the localhost IPv6 address.

Previously, starting from MongoDB 2.6, only the binaries from theofficial MongoDB RPM (Red Hat, CentOS, Fedora Linux, and derivatives)and DEB (Debian, Ubuntu, and derivatives) packages bind to localhost bydefault.

When bound only to the localhost, these MongoDB 3.6 binaries can onlyaccept connections from clients (including the mongo shell,other members in your deployment for replica sets and sharded clusters)that are running on the same machine. Remote clients cannot connect tothe binaries bound only to localhost.

To override and bind to other ip addresses, you can use thenet.bindIp configuration file setting or the—bind_ip command-line option to specify a list of hostnames or ipaddresses.

Warning

Before binding to a non-localhost (e.g. publicly accessible)IP address, ensure you have secured your cluster from unauthorizedaccess. For a complete list of security recommendations, seeSecurity Checklist. At minimum, considerenabling authentication andhardening network infrastructure.

For example, the following mongod instance binds to boththe localhost and the hostname My-Example-Associated-Hostname, which isassociated with the ip address 198.51.100.1:

  1. mongod --bind_ip localhost,My-Example-Associated-Hostname

In order to connect to this instance, remote clients must specifythe hostname or its associated ip address 198.51.100.1:

  1. mongo --host My-Example-Associated-Hostname
  2.  
  3. mongo --host 198.51.100.1

Tip

When possible, use a logical DNS hostname instead of an ip address,particularly when configuring replica set members or sharded clustermembers. The use of logical DNS hostnames avoids configurationchanges due to ip address changes.

Add an Arbiter

Warning

In general, avoid deploying more than one arbiter per replica set.

Tip

When possible, use a logical DNS hostname instead of an ip address,particularly when configuring replica set members or sharded clustermembers. The use of logical DNS hostnames avoids configurationchanges due to ip address changes.

  • Create a data directory (e.g. storage.dbPath) for thearbiter. The mongod instance uses the directory forconfiguration data. The directory will not hold the data set. Forexample, create the /data/arb directory:
  1. mkdir /data/arb
  • Start the arbiter, specifying the data directory and the name of the replica setto join. The following starts an arbiter using the /data/arbas the dbPath and rs for the replica set name:

Warning

Before binding to a non-localhost (e.g. publicly accessible)IP address, ensure you have secured your cluster from unauthorizedaccess. For a complete list of security recommendations, seeSecurity Checklist. At minimum, considerenabling authentication andhardening network infrastructure.

  1. mongod --port 27017 --dbpath /data/arb --replSet rs --bind_ip localhost,<hostname(s)|ip address(es)>
  • Connect to the primary and add the arbiter to the replica set. Usethe rs.addArb() method, as in the following example whichassumes that m1.example.net is the hostname associated with thespecified ip address for the arbiter:
  1. rs.addArb("m1.example.net:27017")

This operation adds the arbiter running on port 27017 on them1.example.net host.