I have a 3-config server setup.
I've restored a backup of one server in a testing environment and trying to restore it as a single server - it starts up fine as a secondary.
csReplSet:SECONDARY> rs.status()
{
"set" : "csReplSet",
"date" : ISODate("2019-06-13T05:27:59.027Z"),
"myState" : 2,
"term" : NumberLong(32),
"configsvr" : true,
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 0,
"name" : "mongo-cfg01:27019",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 3546,
"optime" : {
"ts" : Timestamp(1560399986, 5),
"t" : NumberLong(32)
},
"optimeDate" : ISODate("2019-06-13T04:26:26Z"),
"configVersion" : 4,
"self" : true
},
{
"_id" : 1,
"name" : "mongo-cfg02:27019",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2019-06-13T05:27:58.752Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "Couldn't get a connection within the time limit",
"configVersion" : -1
},
{
"_id" : 2,
"name" : "mongo-cfg03:27019",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2019-06-13T05:27:58.753Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "Couldn't get a connection within the time limit",
"configVersion" : -1
}
],
"ok" : 1
}
Because it's a test environment now, I don't need three servers - one is just fine.
So let's try to remove two of them - doesn't work:
csReplSet:SECONDARY> rs.remove("mongo-cfg02:27019")
{
"ok" : 0,
"errmsg" : "replSetReconfig should only be run on PRIMARY, but my state is SECONDARY; use the \"force\" argument to override",
"code" : 10107
}
Let's try to use force as advised then - still doesn't work:
csReplSet:SECONDARY> rs.remove("
mongo-cfg02.int.timedoctor.com:27019", { force: 1 })
{
"ok" : 0,
"errmsg" : "replSetReconfig should only be run on PRIMARY, but my state is SECONDARY; use the \"force\" argument to override",
"code" : 10107
}
Is my syntax wrong?
Tomasz