Even after provide IP/HOST i still see same issue,somehow still it reads localhost. In windows HOST file also i have set to IP address.
r2schools:PRIMARY> rsconf={_id:"r2schools",members:[{_id:0,host:"10.71.101.186:27017",_id:1,host:"10.71.101.187:27017",_id:2,host:"10.71.136.191:27017"}]}
{
"_id" : "r2schools",
"members" : [
{
"_id" : 2,
"host" : "10.71.136.191:27017"
}
]
}
r2schools:PRIMARY> rs.initiate(rsconf)
{
"operationTime" : Timestamp(1612837719, 1),
"ok" : 0,
"errmsg" : "already initialized",
"code" : 23,
"codeName" : "AlreadyInitialized",
"$clusterTime" : {
"clusterTime" : Timestamp(1612837719, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
r2schools:PRIMARY> rs.add("10.71.101.186:27017")
{
"operationTime" : Timestamp(1612837769, 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(1612837769, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
r2schools:PRIMARY> rs.config()
{
"_id" : "r2schools",
"version" : 1,
"term" : 7,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0,
"host" : "localhost:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : -1,
"catchUpTakeoverDelayMillis" : 30000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("60128e486bd6d3eea3782ebd")
}
}
r2schools:PRIMARY> rs.add("10.71.101.187:27017")
{
"operationTime" : Timestamp(1612837789, 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(1612837789, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
r2schools:PRIMARY> rs.add("10.71.136.191:27017")
{
"operationTime" : Timestamp(1612837789, 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(1612837789, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
}
}
r2schools:PRIMARY> rs.status()
{
"set" : "r2schools",
"date" : ISODate("2021-02-09T02:30:04.835Z"),
"myState" : 1,
"term" : NumberLong(7),
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 1,
"writeMajorityCount" : 1,
"votingMembersCount" : 1,
"writableVotingMembersCount" : 1,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1612837799, 1),
"t" : NumberLong(7)
},
"lastCommittedWallTime" : ISODate("2021-02-09T02:29:59.837Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1612837799, 1),
"t" : NumberLong(7)
},
"readConcernMajorityWallTime" : ISODate("2021-02-09T02:29:59.837Z"),
"appliedOpTime" : {
"ts" : Timestamp(1612837799, 1),
"t" : NumberLong(7)
},
"durableOpTime" : {
"ts" : Timestamp(1612837799, 1),
"t" : NumberLong(7)
},
"lastAppliedWallTime" : ISODate("2021-02-09T02:29:59.837Z"),
"lastDurableWallTime" : ISODate("2021-02-09T02:29:59.837Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1612837759, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "electionTimeout",
"lastElectionDate" : ISODate("2021-02-04T03:39:24.812Z"),
"electionTerm" : NumberLong(7),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1612250005, 1),
"t" : NumberLong(6)
},
"numVotesNeeded" : 1,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"newTermStartDate" : ISODate("2021-02-04T03:39:24.818Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2021-02-04T03:39:24.868Z")
},
"members" : [
{
"_id" : 0,
"name" : "localhost:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 427841,
"optime" : {
"ts" : Timestamp(1612837799, 1),
"t" : NumberLong(7)
},
"optimeDate" : ISODate("2021-02-09T02:29:59Z"),
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1612409964, 1),
"electionDate" : ISODate("2021-02-04T03:39:24Z"),
"configVersion" : 1,
"configTerm" : 7,
"self" : true,
"lastHeartbeatMessage" : ""
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1612837799, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1612837799, 1)
}