MongoDB Replica Build Issue in CentOS

HI Team,

I have started to build mongoDB replica setup. One Primary and two standby DB servers. Primary server and Standby server all configuration completed. I tried to add two standby node in primary but getting the below error. I tested ping primary and both standby, ping also fine. Kindly check and provide your valuable update.

pass-prod:PRIMARY> rs.add( { host: “mongodb1.localdomain.net:27017” } )
{
“operationTime” : Timestamp(1712481013, 1),
“ok” : 0,
“errmsg” : “Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: mongodb.local.com:27017; the following nodes did not respond affirmatively: mongodb1.localdomain.net:27017 failed with Error connecting to mongodb1.localdomain.net:27017 :: caused by :: Could not find address for mongodb1.localdomain.net:27017: SocketException: Host not found (authoritative)”,
“code” : 74,
“codeName” : “NodeNotFound”,
“$clusterTime” : {
“clusterTime” : Timestamp(1712481013, 1),
“signature” : {
“hash” : BinData(0,“ogShPI9if2uT5ZYfKoDdOeZr+CI=”),
“keyId” : NumberLong(“7354806202166935557”)
}
}
}
pass-prod:PRIMARY> rs.add( { host: “mongo2.localdomain.com:27017” } )
{
“operationTime” : Timestamp(1712481023, 1),
“ok” : 0,
“errmsg” : “Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: mongodb.local.com:27017; the following nodes did not respond affirmatively: mongo2.localdomain.com:27017 failed with Error connecting to mongo2.localdomain.com:27017 (64.91.248.15:27017) :: caused by :: Connection refused”,
“code” : 74,
“codeName” : “NodeNotFound”,
“$clusterTime” : {
“clusterTime” : Timestamp(1712481023, 1),
“signature” : {
“hash” : BinData(0,“imCyPsKx4Qzg/Jbru/a7hpdT0+o=”),
“keyId” : NumberLong(“7354806202166935557”)
}
}
}

Hello,

The issue of “node not found” seems to be occurring because the replica set is currently configured based on hostnames rather than IP addresses, and it appears that the hostname cannot be resolved. Therefore, it seems necessary to check if the hostname is correctly configured in the /etc/hosts file.

Thanks for you update. Let me check with OS update and try it. if I will get any more error. I will update here.

Looks like you made some cut-n-paste errors since some of your host are from the domain local.com and others are from localdomain.com.

Do you really have 2 domains?

Can you ping all nodes from every other nodes and from the client you are trying to connect?

Now getting the below error.

MONGODEV:PRIMARY> rs.add( { host: “xxxxxxxxxxx.group.net:27019” } )
{
“operationTime” : Timestamp(1712752704, 1),
“ok” : 0,
“errmsg” : “Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2”,
“code” : 103,
“codeName” : “NewReplicaSetConfigurationIncompatible”,
“$clusterTime” : {
“clusterTime” : Timestamp(1712752704, 1),
“signature” : {
“hash” : BinData(0,“cE9ZPCfmcXRBT01dI1YMQq19zVI=”),
“keyId” : NumberLong(“7356208045132611590”)
}
}
}

Earlier I have 1 primary and 2 standby,. I removed one standby.

current setting:

1 Primary & 1 standby

You are impossible to follow. I already mentioned that you might have a domain name issue by using 2 different one and now you introduced a third one.

Please share your real configuration.

Make sure that what ever you specify in rs.add can be ping from every where. Share the ping commands that confirm this.

Most likely you did rs.add with localhost or 127.0.0.1 rather than a host name.

I have specified hostname and IP address also but no luck.
Both host same network and same domain.

Please share the output of rs.status()

MONGODEV:PRIMARY> rs.add( { host: “hostname:27019” } )
{
“operationTime” : Timestamp(1712752704, 1),
“ok” : 0,
“errmsg” : “Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2”,
“code” : 103,
“codeName” : “NewReplicaSetConfigurationIncompatible”,
“$clusterTime” : {
“clusterTime” : Timestamp(1712752704, 1),
“signature” : {
“hash” : BinData(0,“cE9ZPCfmcXRBT01dI1YMQq19zVI=”),
“keyId” : NumberLong(“7356208045132611590”)
}
}
}

You shared the output rs.add()

And please read Formatting code and log snippets in posts so that what you share is readable.

MONGODEV:PRIMARY> rs.add( { host: “servername.domain.net:27019” } )
{
“operationTime” : Timestamp(1712851362, 1),
“ok” : 0,
“errmsg” : “Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2”,
“code” : 103,
“codeName” : “NewReplicaSetConfigurationIncompatible”,
“$clusterTime” : {
“clusterTime” : Timestamp(1712851362, 1),
“signature” : {
“hash” : BinData(0,“5Gu7J982ZNr74fkzARBqO3N0eXU=”),
“keyId” : NumberLong(“7356208045132611590”)
}
}
}
MONGODEV:PRIMARY> rs.status()
{
“set” : “MONGODEV”,
“date” : ISODate(“2024-04-11T16:02:56.528Z”),
“myState” : 1,
“term” : NumberLong(3),
“syncSourceHost” : “”,
“syncSourceId” : -1,
“heartbeatIntervalMillis” : NumberLong(2000),
“majorityVoteCount” : 1,
“writeMajorityCount” : 1,
“votingMembersCount” : 1,
“writableVotingMembersCount” : 1,
“optimes” : {
“lastCommittedOpTime” : {
“ts” : Timestamp(1712851372, 1),
“t” : NumberLong(3)
},
“lastCommittedWallTime” : ISODate(“2024-04-11T16:02:52.356Z”),
“readConcernMajorityOpTime” : {
“ts” : Timestamp(1712851372, 1),
“t” : NumberLong(3)
},
“readConcernMajorityWallTime” : ISODate(“2024-04-11T16:02:52.356Z”),
“appliedOpTime” : {
“ts” : Timestamp(1712851372, 1),
“t” : NumberLong(3)
},
“durableOpTime” : {
“ts” : Timestamp(1712851372, 1),
“t” : NumberLong(3)
},
“lastAppliedWallTime” : ISODate(“2024-04-11T16:02:52.356Z”),
“lastDurableWallTime” : ISODate(“2024-04-11T16:02:52.356Z”)
},
“lastStableRecoveryTimestamp” : Timestamp(1712851312, 1),
“electionCandidateMetrics” : {
“lastElectionReason” : “electionTimeout”,
“lastElectionDate” : ISODate(“2024-04-11T15:58:02.341Z”),
“electionTerm” : NumberLong(3),
“lastCommittedOpTimeAtElection” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“lastSeenOpTimeAtElection” : {
“ts” : Timestamp(1712755066, 1),
“t” : NumberLong(2)
},
“numVotesNeeded” : 1,
“priorityAtElection” : 1,
“electionTimeoutMillis” : NumberLong(10000),
“newTermStartDate” : ISODate(“2024-04-11T15:58:02.348Z”),
“wMajorityWriteAvailabilityDate” : ISODate(“2024-04-11T15:58:02.449Z”)
},
“members” : [
{
“_id” : 0,
“name” : “127.0.0.1:27019”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 296,
“optime” : {
“ts” : Timestamp(1712851372, 1),
“t” : NumberLong(3)
},
“optimeDate” : ISODate(“2024-04-11T16:02:52Z”),
“lastAppliedWallTime” : ISODate(“2024-04-11T16:02:52.356Z”),
“lastDurableWallTime” : ISODate(“2024-04-11T16:02:52.356Z”),
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“electionTime” : Timestamp(1712851082, 1),
“electionDate” : ISODate(“2024-04-11T15:58:02Z”),
“configVersion” : 1,
“configTerm” : 3,
“self” : true,
“lastHeartbeatMessage” : “”
}
],
“ok” : 1,
“$clusterTime” : {
“clusterTime” : Timestamp(1712851372, 1),
“signature” : {
“hash” : BinData(0,“wGW5PZ7ZdxA063mUwWWQmrjBrKE=”),
“keyId” : NumberLong(“7356208045132611590”)
}
},
“operationTime” : Timestamp(1712851372, 1)
}
MONGODEV:PRIMARY>

Your output is not readable.

1 Like