Error: replset couldn’t find a slave with id 1, not tracking <id>
Causes: After removing and adding replica to MongoDB replica set using rs.add() and rs.remove(), the replica set member id’s don’t follow a continuous order from _id: 0, for example:
{
“_id” : “rs0”,
“version” : 1,
“members” : [
{
“_id” : 4,
“host” : “mongodb0.example.net:27017”
},
{
“_id” : 5,
“host” : “mongodb1.example.net:27017”
},
{
“_id” : 7,
“host” : “mongodb2.example.net:27017”
}
]
}
Solution: You can use rs.reconfig() to re-etablish the order:
var cfg = {
“_id” : “rs0”,
“version” : 1,
“members” : [
{
“_id” : 0,
“host” : “mongodb0.example.net:27017”
},
{
“_id” : 1,
“host” : “mongodb1.example.net:27017”
},
{
“_id” : 2,
“host” : “mongodb2.example.net:27017”
}
]
}
rs.reconfig(cfg);