Database Reference
In-Depth Information
Adding a new machine
In this section, we will add our new machine to the existing replica set. The hostname of
the new node is
mongod2.replicaset.com
.
Using the
rs.add()
function, we will add the new node to the existing replica set as
shown in the following screenshot:
The following screenshot shows the status of the replica set after adding the new node:
The replica set members can have different statuses. You can check the status of a member
using the
state
and
stateStr
fields. The state field shows the status of a member us-
ing an integer value and the
stateStr
field shows the status label.
As you can see, after adding the new node to the existing replica set, the new node's status
is
UNKNOWN
. This is because it is in the initialization phase.
You should wait a while and let the new member communicate with the
primary
node,
and then get the configurations for the replica set and the members relationship. The next
state for the member will be
SECONDARY
and
state ID
is
2
.
Note
You can read more about replica set member's statuses at
http://docs.mongodb.org/manual/