I'm trying to configure replication in 3 machines (OS UbuntuMATE 18.04) with MongoDB v4.0.0 installed.
I'm using Deploy a MongoDB Replica Set link for a reference. and tried to configure as follows...
Step 1: Update all three machine's host file with local-IP and hostnames i.e.
127.0.0.1 localhost
192.168.10.158 dell-Inspiron-15-7000-Gaming
192.168.10.125 dell-1080x2
192.168.10.124 vivek-pc
Then for each machine my /etc/mongod.conf is configured as follows...
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1, 192.168.10.158
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
replication:
replSetName: rs-test
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1, 192.168.10.124
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
replication:
replSetName: rs-test
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1, 192.168.10.125
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
replication:
replSetName: rs-test
Then I've restarted all three MongoDB.
Now here I want following things to know...
mongo
. In all of three instance display as rs-test:PRIMARY>
. (As per the reference there is One Primary and other two are Secondary). So what is wrong here?{ "operationTime" : Timestamp(1544783790, 1), "ok" : 0, "errmsg" : "already initialized", "code" : 23, "codeName" : "AlreadyInitialized", "$clusterTime" : { "clusterTime" : Timestamp(1544783790, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
Any help would be appreciated.
I've Made three changes and now it's working...
Then restarted all three MongoDB instance and add following commands to 192.168.10.158 DB to make it primary.
rs.initiate()
rs.add("dell-1080x2")
rs.add("vivek-pc")