0

I'd like to make a mongo cluster with multiple mongo routers(mongos) with just one shard(mongod) like thses figures.

So I made two mongo routers named 'mongorouter-1', 'mongorouter-2',
and also made one shard named 'mongod'.
Two config servers were made and connected to each mongo routers like the first figure(not like the second figure).
These were made as Docker container with the official Mongo Image
and these were on the same network so they are connected to each other.

In mongorouter-1 I added 'mongod' well with this command.
sh.addShard("mongod:27017")
It works well, but In mongorouter-2 this command put an error, like

mongos> sh.addShard("mongod:27017")
{
    "ok" : 0,
    "errmsg" : "E11000 duplicate key error collection: admin.system.version index: _id_ dup key: { : \"shardIdentity\" }",
    "code" : 11000,
    "codeName" : "DuplicateKey",
    "operationTime" : Timestamp(1558591937, 1),
    "$clusterTime" : {
        "clusterTime" : Timestamp(1558591937, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    }
}  

In mongorouter-1, sh.status is this

mongos> sh.status()
--- Sharding Status --- 
  sharding version: {
    "_id" : 1,
    "minCompatibleVersion" : 5,
    "currentVersion" : 6,
    "clusterId" : ObjectId("5ce6683cc490bfc9325389cb")
  }
  shards:
        {  "_id" : "shard0000",  "host" : "mongod:27017",  "state" : 1 }
  active mongoses:
        "4.0.6" : 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" : "config",  "primary" : "config",  "partitioned" : true }  

and in mongorouter-2, sh.status is this

mongos> sh.status()
--- Sharding Status --- 
  sharding version: {
    "_id" : 1,
    "minCompatibleVersion" : 5,
    "currentVersion" : 6,
    "clusterId" : ObjectId("5ce668176a4dcc52fd230ac9")
  }
  shards:
  active mongoses:
  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" : "config",  "primary" : "config",  "partitioned" : true }

I don't know how to make multiple mongo routers connected to just one shard like the figures.
If you know the solution, help me. Thanks in advance.

  • If you have multiple mongos processes connected to the same sharded cluster they share the same configuration and you do not have to run sh.addShard() on each mongos. However, since each of your sh.status() outputs has a different clusterId it looks like you have configured your config servers independently rather than as Replica Set Config Servers. You should also have 3 config servers, not two. I suggest following the Deploy a Sharded Cluster tutorial in the MongoDB documentation. – Stennie May 24 at 3:29
  • Thanks for your advice, Let me check the site and let each mongos' have the same config server. – eyeballs May 28 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.