Navigation

Add an Arbiter to Replica Set

Arbiters are mongod instances that are part of a replica set but do not hold data. Arbiters participate in elections 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 require dedicated hardware. You can deploy an arbiter on an application server or a monitoring host.

Important

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

Considerations

Replica Set Protocol Version

Note

For the following MongoDB versions, pv1 increases the likelihood of w:1 rollbacks compared to pv0 for replica sets with arbiters:

  • MongoDB 3.4.1
  • MongoDB 3.4.0
  • MongoDB 3.2.11 or earlier

See Replica Set Protocol Versions.

Start Up Configuration

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

To minimize the default creation of data, set the following in the arbiter’s configuration file:

Important

These settings are specific to arbiters.

IP Binding

Starting in MongoDB 3.6, MongoDB binaries, mongod and mongos, bind to localhost (127.0.0.1) by default. If the net.ipv6 configuration file setting or the --ipv6 command line option is set for the binary, the binary additionally binds to the IPv6 address ::1.

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

When bound only to the localhost, these MongoDB 3.6 binaries can only accept 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 to the binaries bound only to localhost.

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

Warning

Before you bind to other ip addresses, consider enabling access control and other security measures listed in Security Checklist to prevent unauthorized access.

For example, the following mongod instance binds to both the localhost and the sample ip address 198.51.100.1:

mongod --bind_ip localhost,198.51.100.1

In order to connect to this instance, remote clients must specify the ip address 198.51.100.1 or the hostname associated with the ip address:

mongo --host 198.51.100.1

mongo --host My-Example-Associated-Hostname

Add an Arbiter

Warning

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

  1. Create a data directory (e.g. storage.dbPath) for the arbiter. The mongod instance uses the directory for configuration data. The directory will not hold the data set. For example, create the /data/arb directory:

    mkdir /data/arb
    
  2. Start the arbiter, specifying the data directory and the name of the replica set to join. The following starts an arbiter using the /data/arb as the dbPath and rs for the replica set name:

    Warning

    Before you bind to other ip addresses, consider enabling access control and other security measures listed in Security Checklist to prevent unauthorized access.

    mongod --port 27017 --dbpath /data/arb --replSet rs --bind_ip localhost,<ip address of the mongod host>
    
  3. Connect to the primary and add the arbiter to the replica set. Use the rs.addArb() method, as in the following example which assumes that m1.example.net is the hostname associated with the specified ip address for the arbiter:

    rs.addArb("m1.example.net:27017")
    

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