MongoDB – エラー「code: 13298」の対処方法について

shard構築後の動作確認をするために、insert・findした時にエラーが発生したのでメモ

環境

  • OS: Ubuntu14.04
  • MongoDB: 3.0.4

shard構成

mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("55a74b5850ca953287ad16e0")
}
shards:
{  "_id" : "set01",  "host" : "set01/mongod11.example.com:27018,mongod12.example.com:27018" }
{  "_id" : "set02",  "host" : "set02/mongod21.example.com:27018,mongod82.example.com:27018" }
balancer:
Currently enabled:  no
Currently running:  no
Failed balancer rounds in last 5 attempts:  0
Migration Results for the last 24 hours:
No recent migrations
databases:
{  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
{  "_id" : "testdb",  "partitioned" : true,  "primary" : "set01" }
testdb.collectiontest
shard key: { "skey" : 1 }
chunks:
set01   1
{ "skey" : { "$minKey" : 1 } } -->> { "skey" : { "$maxKey" : 1 } } on : set01 Timestamp(1, 0)
{  "_id" : "collectiontest",  "partitioned" : false,  "primary" : "set02" }
mongos>

エラーメッセージ

まずテストデータをinsertしたら以下のエラーメッセージ

mongos> use testdb
mongos> db.collectiontest.insert({skey:1, name:"yamada"})
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 82,
"errmsg" : "no progress was made executing batch write op in testdb.collectiontest after 5 rounds (0 ops completed in 6 rounds total)"
}
})
mongos>

そしてfindしたら以下のエラーメッセージ

mongos> use testdb
mongos> db.collectiontest.find();
Error: error: {
"$err" : "setShardVersion failed shard: set01:set01/mongod11.example.com:27018,mongod12.example.com:27018 { errmsg: \"exception: remote client 10.0.22.71:56638 tried to initialize this host (set01/mongod11.example.com:27018,mongod12.te...\", code: 13298, ok: 0.0, $gleStats: { lastOpTime: Timestamp 0|0, electionId: ObjectId('55a7277a6037b3179737b77b') } }",
"code" : 10429,
"shard" : "set01"
mongos>

対応

mongodを再起動すると復旧するとのこと
早速mongodと念のためmongos再起動して実行した結果がこちら

mongos> use testdb
mongos> db.collectiontest.insert({skey:1, name:"yamada"})
WriteResult({ "nInserted" : 1 })
mongos> db.collectiontest.find()
{ "_id" : ObjectId("55a7650fa2708fabb9475021"), "skey" : 1, "name" : "yamada" }

原因はよくわからなかったので、ご存じの方がおりましたら教えて下さい

参考

mongodb sharded collection query failed: setShardVersion failed host
I have encountered a problem after adding a shard to mongodb cluster. I did the following operations: 1. deploy a mongodb cluster with primary shard named '...
タイトルとURLをコピーしました