|
Following is my mongo configuration file for both primary and all other secondary node.
On both server I am using mongodb version 4.2.6
|
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: 0.0.0.0
|
|
|
# how the process runs
|
processManagement:
|
timeZoneInfo: /usr/share/zoneinfo
|
fork: true
|
|
security:
|
authorization: enabled
|
keyFile: /data/pki/mongo-keyfile
|
|
replication:
|
replSetName: m1-replica
|
oplogSizeMB: 10000
|
|
For Initiation of replica set I did following steps
enable the auth
login with that user
then added
rs.add(\{"host": "ip:27017", votes: 0, priority: 0})
|
Following is output from rs.status() on primary
{
|
"set" : "m1-replica",
|
"date" : ISODate("2020-10-03T20:53:53.815Z"),
|
"myState" : 1,
|
"term" : NumberLong(1),
|
"syncingTo" : "",
|
"syncSourceHost" : "",
|
"syncSourceId" : -1,
|
"heartbeatIntervalMillis" : NumberLong(2000),
|
"majorityVoteCount" : 1,
|
"writeMajorityCount" : 1,
|
"optimes" : {
|
"lastCommittedOpTime" : {
|
"ts" : Timestamp(1601758421, 1),
|
"t" : NumberLong(1)
|
},
|
"lastCommittedWallTime" : ISODate("2020-10-03T20:53:41.494Z"),
|
"readConcernMajorityOpTime" : {
|
"ts" : Timestamp(1601758421, 1),
|
"t" : NumberLong(1)
|
},
|
"readConcernMajorityWallTime" : ISODate("2020-10-03T20:53:41.494Z"),
|
"appliedOpTime" : {
|
"ts" : Timestamp(1601758421, 1),
|
"t" : NumberLong(1)
|
},
|
"durableOpTime" : {
|
"ts" : Timestamp(1601758421, 1),
|
"t" : NumberLong(1)
|
},
|
"lastAppliedWallTime" : ISODate("2020-10-03T20:53:41.494Z"),
|
"lastDurableWallTime" : ISODate("2020-10-03T20:53:41.494Z")
|
},
|
"lastStableRecoveryTimestamp" : Timestamp(1601758421, 1),
|
"lastStableCheckpointTimestamp" : Timestamp(1601758421, 1),
|
"electionCandidateMetrics" : {
|
"lastElectionReason" : "electionTimeout",
|
"lastElectionDate" : ISODate("2020-10-03T09:52:46.991Z"),
|
"electionTerm" : NumberLong(1),
|
"lastCommittedOpTimeAtElection" : {
|
"ts" : Timestamp(0, 0),
|
"t" : NumberLong(-1)
|
},
|
"lastSeenOpTimeAtElection" : {
|
"ts" : Timestamp(1601718766, 1),
|
"t" : NumberLong(-1)
|
},
|
"numVotesNeeded" : 1,
|
"priorityAtElection" : 1,
|
"electionTimeoutMillis" : NumberLong(10000),
|
"newTermStartDate" : ISODate("2020-10-03T09:52:47.054Z"),
|
"wMajorityWriteAvailabilityDate" : ISODate("2020-10-03T09:52:47.092Z")
|
},
|
"members" : [
|
{
|
"_id" : 0,
|
"name" : "tmi-mlab-01:27017",
|
"health" : 1,
|
"state" : 1,
|
"stateStr" : "PRIMARY",
|
"uptime" : 40199,
|
"optime" : {
|
"ts" : Timestamp(1601758421, 1),
|
"t" : NumberLong(1)
|
},
|
"optimeDate" : ISODate("2020-10-03T20:53:41Z"),
|
"syncingTo" : "",
|
"syncSourceHost" : "",
|
"syncSourceId" : -1,
|
"infoMessage" : "",
|
"electionTime" : Timestamp(1601718767, 1),
|
"electionDate" : ISODate("2020-10-03T09:52:47Z"),
|
"configVersion" : 113846,
|
"self" : true,
|
"lastHeartbeatMessage" : ""
|
},
|
{
|
"_id" : 1,
|
"name" : "ip:27017",
|
"health" : 1,
|
"state" : 0,
|
"stateStr" : "STARTUP",
|
"uptime" : 702,
|
"optime" : {
|
"ts" : Timestamp(0, 0),
|
"t" : NumberLong(-1)
|
},
|
"optimeDurable" : {
|
"ts" : Timestamp(0, 0),
|
"t" : NumberLong(-1)
|
},
|
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
|
"optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),
|
"lastHeartbeat" : ISODate("2020-10-03T20:53:53.715Z"),
|
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
|
"pingMs" : NumberLong(0),
|
"lastHeartbeatMessage" : "",
|
"syncingTo" : "",
|
"syncSourceHost" : "",
|
"syncSourceId" : -1,
|
"infoMessage" : "",
|
"configVersion" : -2
|
}
|
],
|
"ok" : 1,
|
"$clusterTime" : {
|
"clusterTime" : Timestamp(1601758421, 1),
|
"signature" : {
|
"hash" : BinData(0,"QmM13sXXXR5FpTNhRAVKFWdtAjw="),
|
"keyId" : NumberLong("6879329721654444035")
|
}
|
},
|
"operationTime" : Timestamp(1601758421, 1)
|
}
|
Following is output of `rs.isMaster()` secondary which I added using` rs.add()`
"ismaster" : false,
|
"secondary" : false,
|
"info" : "Does not have a valid replica set config",
|
"isreplicaset" : true,
|
"maxBsonObjectSize" : 16777216,
|
"maxMessageSizeBytes" : 48000000,
|
"maxWriteBatchSize" : 100000,
|
"localTime" : ISODate("2020-10-03T20:48:59.266Z"),
|
"logicalSessionTimeoutMinutes" : 30,
|
"connectionId" : 7,
|
"minWireVersion" : 0,
|
"maxWireVersion" : 8,
|
"readOnly" : false,
|
"ok" : 1
|
|