简体   繁体   English

群集上的MongoDB查询问题

[英]MongoDB query issue on cluster

I have created cluster with 2 shards. 我创建了具有2个分片的集群。 Please check my shards status below. 请检查下面的分片状态。

shards:
        {  "_id" : "shard0000",  "host" : "172.20.1.66:27021" }
        {  "_id" : "shard0001",  "host" : "172.20.1.66:27022" }
  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" : "admin",  "partitioned" : false,  "primary" : "config" }
        {  "_id" : "symfony",  "partitioned" : false,  "primary" : "shard0000" }
        {  "_id" : "testDB",  "partitioned" : true,  "primary" : "shard0001" }
                testDB.products
                        shard key: { "_id" : "hashed" }
                        chunks:
                                shard0001       2
                        { "_id" : { "$minKey" : 1 } } -->> { "_id" : NumberLong(0) } on : shard0001 Timestamp(1, 0)
                        { "_id" : NumberLong(0) } -->> { "_id" : { "$maxKey" : 1 } } on : shard0001 Timestamp(1, 1)

I have inserted more than 100000 docs and tried to fetch data using query. 我插入了超过100000个文档,并尝试使用查询获取数据。

db.products.find();

It is returning error as shown below. 它返回错误,如下所示。

Error: error: {
        "$err" : "setShardVersion failed shard: shard0001:172.20.1.66:27022 { oldVersion: Timestamp 0|0, oldVersionEpoch: ObjectId('000000000000000000000000'), ns: \"testDB.products\", version: Timestamp 1000|1, versionEpoch: ObjectId('5668170dbd53962a250383f8'), globalVersion: Timestamp 0|0, globalVersionEpoch: ObjectId('000000000000000000000000'), reloadConfig: true, ok: 0.0, errmsg: \"could not refresh metadata for testDB.products with requested shard version 1|1||5668170dbd53962a250383f8, stored shard version is 0|0||00000000000000...\" }",
        "code" : 10429,
        "shard" : "shard0001"
}

Can some one help me to resolve this issue. 有人可以帮我解决这个问题。

I have seen this error happening when some of the servers could not contact the config servers. 我看到当某些服务器无法联系配置服务器时发生此错误。 Please make sure: 请确保:

  • That your config server(s) are up and running. 您的配置服务器已启动并正在运行。
  • That your mongos instance can contact the config server(s). 你的mongos实例可以联系配置服务器。
  • That all mongod instances can contact the config server(s). 所有mongod实例都可以联系配置服务器。

Also, look into the logs of all servers in your setup and look for errors. 另外,查看设置中所有服务器的日志并查找错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM