Hello everyone, hope you all are doing great.
I am new to Mongodb and recently started studying it. i have came across an issue that i am unable to solve, so your help will be apprecited.
So the issue is that, i have a 2 node replicaset in virtualbox. The priority od node 1 is higher then that of node 2. but when the secondary node is switched off, Primaryt takes the position of secondary which shouldn’t be happening since it’s priority is higher than that of Secondary. please revire the followinf output of rs.status(), rs.conf() and mongod.conf file. Thanks
rs.status()
{
set: 'dev',
date: ISODate("2021-10-26T05:42:04.263Z"),
myState: 2,
term: Long("75"),
syncSourceHost: '',
syncSourceId: -1,
heartbeatIntervalMillis: Long("2000"),
majorityVoteCount: 2,
writeMajorityCount: 2,
votingMembersCount: 2,
writableVotingMembersCount: 2,
optimes: {
lastCommittedOpTime: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") },
lastCommittedWallTime: ISODate("1970-01-01T00:00:00.000Z"),
appliedOpTime: { ts: Timestamp({ t: 1635157792, i: 1 }), t: Long("75") },
durableOpTime: { ts: Timestamp({ t: 1635157792, i: 1 }), t: Long("75") },
lastAppliedWallTime: ISODate("2021-10-25T10:29:52.306Z"),
lastDurableWallTime: ISODate("2021-10-25T10:29:52.306Z")
},
lastStableRecoveryTimestamp: Timestamp({ t: 1635157782, i: 1 }),
members: [
{
_id: 0,
name: '192.168.10.35:27017',
health: 1,
state: 2,
stateStr: 'SECONDARY',
uptime: 546,
optime: { ts: Timestamp({ t: 1635157792, i: 1 }), t: Long("75") },
optimeDate: ISODate("2021-10-25T10:29:52.000Z"),
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
configVersion: 4,
configTerm: 75,
self: true,
lastHeartbeatMessage: ''
},
{
_id: 1,
name: 'mongo2:27017',
health: 0,
state: 8,
stateStr: '(not reachable/healthy)',
uptime: 0,
optime: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") },
optimeDurable: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") },
optimeDate: ISODate("1970-01-01T00:00:00.000Z"),
optimeDurableDate: ISODate("1970-01-01T00:00:00.000Z"),
lastHeartbeat: ISODate("2021-10-26T05:42:02.040Z"),
lastHeartbeatRecv: ISODate("1970-01-01T00:00:00.000Z"),
pingMs: Long("0"),
lastHeartbeatMessage: 'Error connecting to mongo2:27017 (192.168.10.36:27017) :: caused by :: No route to host',
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
configVersion: -1,
configTerm: -1
}
],
ok: 1
}
rs.conf()
{
_id: 'dev',
version: 4,
term: 75,
members: [
{
_id: 0,
host: '192.168.10.35:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 2,
tags: {},
secondaryDelaySecs: Long("0"),
votes: 1
},
{
_id: 1,
host: 'mongo2:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long("0"),
votes: 1
}
],
protocolVersion: Long("1"),
writeConcernMajorityJournalDefault: true,
settings: {
chainingAllowed: true,
heartbeatIntervalMillis: 2000,
heartbeatTimeoutSecs: 10,
electionTimeoutMillis: 10000,
catchUpTimeoutMillis: -1,
catchUpTakeoverDelayMillis: 30000,
getLastErrorModes: {},
getLastErrorDefaults: { w: 1, wtimeout: 0 },
replicaSetId: ObjectId("615cbca9b21c4aa8b7747237")
mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# wiredTiger:
# 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.35
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: enabled
keyFile: /home/mongo1/mongodb/keyfile.txt
#operationProfiling:
replication:
replSetName: dev
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp: