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...
mongod.conf 192.168.10.158
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
mongod.conf 192.168.10.124
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
mongod.conf 192.168.10.125
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...
- The steps which I've followed is correct for MongoDB V4?
- After restart when I'm connecting to mongo by using shell command
mongo
. In all of three instance display asrs-test:PRIMARY>
. (As per the reference there is One Primary and other two are Secondary). So what is wrong here? - When I'm trying to initiate the replica set in One machine using rs.initiate(). it returns me following error message...
{ "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.