- Replication >
- Replica Set Tutorials >
- Replica Set Deployment Tutorials >
- Add an Arbiter to Replica Set
Add an Arbiter to Replica Set¶
On this page
In some circumstances (such as you have a primary and a secondary but
cost constraints prohibit adding another secondary), you may choose to
add a mongod instance to a replica set as an
arbiter to vote in elections.
Arbiters are mongod instances that are part of a
replica set but do not hold data (i.e. do not provide data
redundancy). They can, however, participate in elections.
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 the same system as a member of the replica set.
Warning
In general, avoid deploying more than one arbiter per replica set.
Considerations¶
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
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
The following setting is specific to arbiters.
- For MMAPv1 storage engine,
storage.mmapv1.smallFilestotrue
These settings are specific to arbiters. Do not set
storage.journal.enabled to false on a
data-bearing node. Similarly, do not set storage.mmapv1.smallFiles
unless specifically indicated.
Add an Arbiter¶
Warning
In general, avoid deploying more than one arbiter per replica set.
Create a data directory (e.g.
storage.dbPath) for the arbiter. Themongodinstance uses the directory for configuration data. The directory will not hold the data set. For example, create the/var/lib/mongodb/arbdirectory:Start the arbiter, specifying the data directory and the name of the replica set to join. The following starts an arbiter using the
/var/lib/mongodb/arbas thedbPathandrsfor the replica set name:Connect to the primary and add the arbiter to the replica set. Use the
rs.addArb()method, as in the following example:This operation adds the arbiter running on port
30000on them1.example.nethost.