Search code examples
mongodbshardingreplicaset

Mongo "setShardVersion failed"


I had a mongodb with 4 shards, then I created another 4 sharded mongo instance in another server and configured replica sets, after that I got the bellow error when I want to query the first mongo (writing to db also fails!)

Error: error: {
"$err" : "setShardVersion failed shard: shard0001:127.0.0.1:27122 { errmsg: \"not master\", note: \"from post init in setShardVersion\", ok: 0.0, $gleStats: { lastOpTime: Timestamp 0|0, electionId: ObjectId('000000000000000000000000') } }",
"code" : 10429,
"shard" : "shard0001"}

I want to know what does \"not master\" means and what causes this error?

Regards.


Solution

  • Mongo not allows writes to secondary server.

    Mongo allows reads from secondaries by enabling slaveOK command

    rs.slaveOk()
    

    manual