MongoDB分片文档插入

时间:2017-03-03 13:55:32

标签: mongodb sharding

我创建了一个碎片,状态似乎很好

--- Sharding Status --- 
  sharding version: {
    "_id" : 1,
    "minCompatibleVersion" : 5,
    "currentVersion" : 6,
    "clusterId" : ObjectId("58aefb3181741b40c635c327")
}
  shards:
    {  "_id" : "repl1",  "host" : "repl1/prod-mongo-repl1:27017,prod-mongo-repl1:27018,prod-mongo-repl1:27019",  "state" : 1 }
    {  "_id" : "repl2",  "host" : "repl2/prod-mongo-repl2:27017,prod-mongo-repl2:27018,prod-mongo-repl2:27019",  "state" : 1 }
  active mongoses:
    "3.4.2" : 1
 autosplit:
    Currently enabled: yes
  balancer:
    Currently enabled:  yes
    Currently running:  no
    Failed balancer rounds in last 5 attempts:  0
    Migration Results for the last 24 hours: 
        No recent migrations
  databases:
    {  "_id" : "mydatabase",  "primary" : "repl1",  "partitioned" : true }
        mydatabase.extract_purchases
            shard key: { "month" : 1, "year" : 1 }
            unique: false
            balancing: true
            chunks:
                repl1   1
            { "month" : { "$minKey" : 1 }, "year" : { "$minKey" : 1 } } -->> { "month" : { "$maxKey" : 1 }, "year" : { "$maxKey" : 1 } } on : repl1 Timestamp(1, 0) 

但是现在,尝试插入或事件只运行一个find命令不起作用,我在几秒钟/几分钟后收到这种消息:

尝试:

db.extract_purchases.insert({year:2017, month:1})

结果是

WriteResult({
    "nInserted" : 0,
    "writeError" : {
        "code" : 82,
        "errmsg" : "no progress was made executing batch write op in mydatabase.extract_purchases after 5 rounds (0 ops completed in 6 rounds total)"
    }
})

我不知道该怎么办......我在“mongos”的外壳中

非常感谢您提前帮助!!

1 个答案:

答案 0 :(得分:0)

我们在生产中有一个碎片,我从未见过这个错误。

您是否可以检查每个副本集的运行状况(Config,repl1& repl2)以确保每个副本集都有主要内容? (你必须直接连接到每个副本集的成员来检查,你不能通过mongos来实现)

当您尝试插入或读取数据时,是否还可以检查原色的日志(特别是repl1,因为目前只有1个块)?

您是否也可以尝试写入同一数据库的未整理的集合?和另一个数据库?

Henri-Maxime(来自里尔,有人派我来这里......)