Passive nodes in Mongodb replica set

Hello Everyone, I have an issue with converting a standalone to a replica set in windows platform:

I have three servers using windows

1.) DESKTOP-MONGO01:27017 // Contain the old databases
2.) DESKTOP-MONGO02:27017 // New Device
3.) DESKTOP-MONGO03:27017 // New Device

DESKTOP-MONGO01:27017 - CFG

net:
  port: 27017
  bindIp: 127.0.0.1,DESKTOP-MONGO01,10.15.22.58

security:
 keyFile: C:\mongocluster\key.txt

replication:
 replSetName: "rs0"

DESKTOP-MONGO02:27017 - CFG

net:
  port: 27017
  bindIp: 127.0.0.1,DESKTOP-MONGO02,10.15.22.59

security:
 keyFile: C:\mongocluster\key.txt

replication:
 replSetName: "rs0"

DESKTOP-MONGO03:27017 - CFG

net:
  port: 27017
  bindIp: 127.0.0.1,DESKTOP-MONGO03,10.15.22.60

security:
 keyFile: C:\mongocluster\key.txt

replication:
 replSetName: "rs0"

after adding the second node in DESKTOP-MONGO01 and run rs.isMaster(); I got the following:

{
        "topologyVersion" : {
                "processId" : ObjectId("641edc16215a2bead7ec5e3b"),
                "counter" : NumberLong(7)
        },
        "hosts" : [
                "DESKTOP-MONGO01:27017"
        ],
        "passives" : [
                "DESKTOP-MONGO02:27017"
        ],
        "setName" : "rs0",
        "setVersion" : 2,
        "ismaster" : true,
        "secondary" : false,
        "primary" : "DESKTOP-MONGO01:27017",
        "me" : "DESKTOP-MONGO01:27017",
        "electionId" : ObjectId("7fffffff0000000000000001"),
        "lastWrite" : {
                "opTime" : {
                        "ts" : Timestamp(1679744105, 1),
                        "t" : NumberLong(1)
                },
                "lastWriteDate" : ISODate("2023-03-25T11:35:05Z"),
                "majorityOpTime" : {
                        "ts" : Timestamp(1679744105, 1),
                        "t" : NumberLong(1)
                },
                "majorityWriteDate" : ISODate("2023-03-25T11:35:05Z")
        },
        "maxBsonObjectSize" : 16777216,
        "maxMessageSizeBytes" : 48000000,
        "maxWriteBatchSize" : 100000,
        "localTime" : ISODate("2023-03-25T11:35:11.492Z"),
        "logicalSessionTimeoutMinutes" : 30,
        "connectionId" : 1,
        "minWireVersion" : 0,
        "maxWireVersion" : 13,
        "readOnly" : false,
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1679744105, 1),
                "signature" : {
                        "hash" : BinData(0,"Gv67T8xqXrQIMfb5QlKCN2Khzxg="),
                        "keyId" : NumberLong("7214139855649898500")
                }
        },
        "operationTime" : Timestamp(1679744105, 1)
}

and rs.status();

{
        "set" : "rs0",
        "date" : ISODate("2023-03-25T11:35:28.278Z"),
        "myState" : 1,
        "term" : NumberLong(1),
        "syncSourceHost" : "",
        "syncSourceId" : -1,
        "heartbeatIntervalMillis" : NumberLong(2000),
        "majorityVoteCount" : 1,
        "writeMajorityCount" : 1,
        "votingMembersCount" : 1,
        "writableVotingMembersCount" : 1,
        "optimes" : {
                "lastCommittedOpTime" : {
                        "ts" : Timestamp(1679744125, 1),
                        "t" : NumberLong(1)
                },
                "lastCommittedWallTime" : ISODate("2023-03-25T11:35:25.820Z"),
                "readConcernMajorityOpTime" : {
                        "ts" : Timestamp(1679744125, 1),
                        "t" : NumberLong(1)
                },
                "appliedOpTime" : {
                        "ts" : Timestamp(1679744125, 1),
                        "t" : NumberLong(1)
                },
                "durableOpTime" : {
                        "ts" : Timestamp(1679744125, 1),
                        "t" : NumberLong(1)
                },
                "lastAppliedWallTime" : ISODate("2023-03-25T11:35:25.820Z"),
                "lastDurableWallTime" : ISODate("2023-03-25T11:35:25.820Z")
        },
        "lastStableRecoveryTimestamp" : Timestamp(1679744105, 1),
        "electionCandidateMetrics" : {
                "lastElectionReason" : "electionTimeout",
                "lastElectionDate" : ISODate("2023-03-25T11:34:15.724Z"),
                "electionTerm" : NumberLong(1),
                "lastCommittedOpTimeAtElection" : {
                        "ts" : Timestamp(1679744054, 1),
                        "t" : NumberLong(-1)
                },
                "lastSeenOpTimeAtElection" : {
                        "ts" : Timestamp(1679744054, 1),
                        "t" : NumberLong(-1)
                },
                "numVotesNeeded" : 1,
                "priorityAtElection" : 1,
                "electionTimeoutMillis" : NumberLong(10000),
                "newTermStartDate" : ISODate("2023-03-25T11:34:15.813Z"),
                "wMajorityWriteAvailabilityDate" : ISODate("2023-03-25T11:34:15.835Z")
        },
        "members" : [
                {
                        "_id" : 0,
                        "name" : "DESKTOP-MONGO01:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 106,
                        "optime" : {
                                "ts" : Timestamp(1679744125, 1),
                                "t" : NumberLong(1)
                        },
                        "optimeDate" : ISODate("2023-03-25T11:35:25Z"),
                        "lastAppliedWallTime" : ISODate("2023-03-25T11:35:25.820Z"),
                        "lastDurableWallTime" : ISODate("2023-03-25T11:35:25.820Z"),
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "Could not find member to sync from",
                        "electionTime" : Timestamp(1679744055, 1),
                        "electionDate" : ISODate("2023-03-25T11:34:15Z"),
                        "configVersion" : 2,
                        "configTerm" : 1,
                        "self" : true,
                        "lastHeartbeatMessage" : ""
                },
                {
                        "_id" : 1,
                        "name" : "DESKTOP-MONGO02:27017",
                        "health" : 1,
                        "state" : 0,
                        "stateStr" : "STARTUP",
                        "uptime" : 45,
                        "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"),
                        "lastAppliedWallTime" : ISODate("1970-01-01T00:00:00Z"),
                        "lastDurableWallTime" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2023-03-25T11:35:26.859Z"),
                        "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
                        "pingMs" : NumberLong(1),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "configVersion" : -2,
                        "configTerm" : -1
                }
        ],
        "ok" : 1,
        "$clusterTime" : {
                "clusterTime" : Timestamp(1679744125, 1),
                "signature" : {
                        "hash" : BinData(0,"1NoyQRpJW7Ug/NhwNZAXA18lX9c="),
                        "keyId" : NumberLong("7214139855649898500")
                }
        },
        "operationTime" : Timestamp(1679744125, 1)
}

rs.conf()

{
        "_id" : "rs0",
        "version" : 2,
        "term" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "DESKTOP-MONGO01:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "secondaryDelaySecs" : NumberLong(0),
                        "votes" : 1
                },
                {
                        "_id" : 1,
                        "host" : "DESKTOP-MONGO02:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "secondaryDelaySecs" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "protocolVersion" : NumberLong(1),
        "writeConcernMajorityJournalDefault" : true,
        "settings" : {
                "chainingAllowed" : true,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "catchUpTimeoutMillis" : -1,
                "catchUpTakeoverDelayMillis" : 30000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                },
                "replicaSetId" : ObjectId("641edc36215a2bead7ec5e65")
        }
}

I am new to MongoDB replica set so I don’t know what is the issue? The old structure was standalone with authentication enabled, so it will be good if I got some help,

Thank you.

Check the secondary mongod.log
Is keyfile the same on all nodes?
Can you connect from primary to your secondary
Could be firewall blocking?
Is hosts file/hostname resolution fine?

1 Like

Thank you for response, It was firewall issue, Once I white listed the port 27017 on the master pc its works fine.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.