Database Reference
In-Depth Information
Primary data center
Secondary data center
Secondary
Ping
Replication
Secondary
Ping
Ping
Primary
Figure 8.1 A basic replica set
consisting of a primary, a
secondary, and an arbiter
If you examine the mongod log output, the first thing you'll notice are error messages
saying that the configuration can't be found. The is completely normal:
[startReplSets] replSet can't get local.system.replset
config from self or any seed (EMPTYCONFIG)
[startReplSets] replSet info you may need to run replSetInitiate
To p r o c e e d , y o u n e e d t o c o n f i g u r e t h e r e p l i c a s e t . D o s o b y f ir s t co nn e ct in g t o o n e o f
the non-arbiter mongod s just started. These examples were produced running these
mongod processes locally, so you'll connect via the local hostname, in this case, arete .
Connect, and then run the rs.initiate() command:
> rs.initiate()
{
"info2" : "no configuration explicitly specified -- making one",
"me" : "arete:40000",
"info" : "Config now saved locally. Should come online in about a minute
.",
"ok" : 1
}
Within a minute or so, you'll have a one-member replica set. You can now add the
other two members using rs.add() :
> rs.add("localhost:40001")
{ "ok" : 1 }
> rs.add("arete.local:40002", {arbiterOnly: true})
{ "ok" : 1 }
Note that for the second node, you specify the arbiterOnly option to create an arbi-
ter. Within a minute, all members should be online. To get a brief summary of the rep-
lica set status, run the db.isMaster() command:
Search WWH ::




Custom Search