Initiate the Replica Set
Initiate the replica set to be used for the Event Repository.
The replica set is the group of mongod
instances that hosts the MATRIXX
event-object data set in your MongoDB system.
Before you begin
- Verify that the
replication
option is set toMtxEventReplSet
. - Verify that the
authorization
option is set toenabled
. - Verify that all
mongod
instances on each of the MongoDB host servers are started.
--nojournal
option or storage.journal.enabled:
false
for replica set members that use the WiredTiger storage
engine. Refer to the MongoDB product documentation for compatibility changes in
MongoDB 4.0.Verify that each member of the replica set is accessible using a resolvable DNS or host name. Either configure your DNS names appropriately or set up your systems' /etc/hosts file to reflect this configuration. For more information, see the MongoDB documentation.
About this task
The instructions in this procedure initiates a single replica set with
three
mongod
instances.
Procedure
-
Connect to one of the
mongod
instances locally. -
Using the MongoDB mongo shell CLI, enter the
rs.initiate()
command to initiate the replica set:mongors.initiate({"_id" : "MtxEventReplSet","members" : [{"_id" : 0, "host" : "ip1", "arbiterOnly": false},{"_id" : 1, "host" : "ip2", "arbiterOnly": false},{"_id" : 2, "host" : "ip3", "arbiterOnly": false}]})where:- ip1, ip2, and ip3 are the hostnames (or IP addresses) and port numbers of the host servers where mongod instances of the replica set are to run. The port number is required only if the port number is not the default (27017).
- The
arbiterOnly
option is set totrue
if themongod
instance is to run as an arbiter only.
For example:
mongo --host 192.0.2.0 rs.initiate({ "_id" : "MtxEventReplSet", "members" : [ {"_id" : 0, "host" : "dbhost01", "arbiterOnly": false}, {"_id" : 1, "host" : "10.10.10.2", "arbiterOnly": false}, {"_id" : 2, "host" : "dbhost033:27020", "arbiterOnly": true} ] }) { "ok" : 1 }
-
Identify the replica set primary (
mongod
primary) by issuing the mongo shell CLI commandrs.status()
on any server.A few seconds after the replica set is initialized, one
mongod
instance is elected as the primary of the replica set. All changes to the replica set must be done when connected to the primary from this point in the setup instructions.
What to do next
Now that the replica set is initialized, create replica set users. You must be connected to the replica set primary to create the users.