Database Reference
In-Depth Information
[ priority: <priority>, ]
[arbiterOnly : true, ]
[ votes : <n>, ]
[ hidden: true, ]
[ tags: { document }, ]
[ slaveDelay: <seconds>, ]
[ buildIndexes: true, ]
}
, ...
],
settings: {
[ chainingAllowed : <boolean>, ]
[ getLastErrorModes: <modes>, ]
[ getLastErrorDefaults: <lasterrdefaults>, ]
}
}
For
rs.initiate()
, you should supply the full configuration structure, as shown here. The topmost level of the
configuration structure itself includes three levels:
_id
,
members
, and
settings
. The
_id
is the name of the replica set,
as supplied with the
--replSet
command-line option when you create the replica set members. The
members
array
consists of a set of structures that describe each member of the set; this is the member structure that you supply to
the
rs.add()
command when adding an individual server to the set. Finally, the
settings
array contains options that
apply to the entire replica set.
Organization of the members Structure
The
members
structure contains all the entries required to configure each of the member instances of the replica set;
you can see all of these entries listed in Table
11-4
.
Table 11-4.
Configuring Member Server Properties
Option
Description
members.$._id
(Mandatory) Integer: This element specifies the ordinal position of the member
structure in the
member
array. Possible values for this element include integers greater
than or equal to
0
. This value enables you to address specific member structures, so you
can perform add, remove, and overwrite operations.
members.$.host
(Mandatory) String: This element specifies the name of the server in the form
host:port
; note that the host portion
cannot
be
localhost
or
127.0.0.1
.
members.$.priority
(Optional) Float: The element represents the
weight
assigned to the server when
elections for a new primary server are conducted. If the primary server becomes
unavailable, then a secondary server will be promoted based on this value. Any
secondary server with a nonzero value is considered to be active and eligible to become
a primary server. Thus, setting this value to zero forces the secondary to become passive.
If multiple secondary servers share equal priority, then a vote will be taken, and an
arbiter (if configured) may be called upon to resolve any deadlocks. The default value for
this element is
1.0
.
(
continued
)