1

As I am new with MongoDB.

I have configured 2 config server, 2 shards and all are connected with mongod client. Also, One Mongos client is UP and Running.

I am currenctly implementing Sharding using Mongo Zone. As I have to store the data accourding to country/Zone. But facing below error in shards:

2018-05-03T16:22:40.200+0530 W SHARDING [conn13] Chunk move failed :: caused by :: 
      NoShardingEnabled: Cannot accept sharding commands if not started with --shardsvr
2018-05-03T16:27:11.223+0530 I SHARDING [Balancer] Balancer move testdb.user: 
      [{ zipcode: "380001" }, { zipcode: "39000" }), from rs1, to rs0 failed :: caused by :: 
      NoShardingEnabled: Cannot accept sharding commands if not started with --shardsvr

I have already started server with --shardsvr and also mentioned in config file as well. But still I am facing issue.

Below are the all config files:

mongosconfig.cfg

systemLog:
  destination: file
  path: "c:\\data\\log\\mongos.log"
  logAppend: true
sharding:
  configDB: "rs0/192.168.1.113:27017,192.168.1.112:27017"
net:
  bindIp: 192.168.1.113
  port: 27018

mongoclientconfig.cfg - configserver1

systemLog:
  destination: file
  path: "c:\\data\\log\\mongoclient.log"
  logAppend: true
storage:
  dbPath: "c:\\data\\db\\configdb"
  journal:
    enabled: true
sharding:
  clusterRole: "configsvr"
net:
  bindIp: 192.168.1.113
  port: 27017
replication:
  replSetName: "rs0"

mongodconfig.cfg - shard1

systemLog:
  destination: file
  path: "c:\\data\\log\\mongod.log"
  logAppend: true
storage:
  dbPath: "c:\\data\\db\\clientdb"
  journal:
    enabled: true
sharding:
  clusterRole: "shardsvr"
net:
  bindIp: 192.168.1.113
  port: 27019
replication:
  replSetName: "rs0"

mongoclientconfig.cfg - configserver2

systemLog:
  destination: file
  path: "D:\\data\\log\\mongoclient.log"
  logAppend: true
storage:
  dbPath: "D:\\data\\db\\configdb"
  journal:
    enabled: true
sharding:
  clusterRole: "configsvr"
replication:
  replSetName: "rs1"
net:
  bindIp: 192.168.1.112
  port: 27017

mongodconfig.cfg - Shard2

systemLog:
  destination: file
  path: "D:\\data\\log\\mongod.log"
  logAppend: true
storage:
  dbPath: "D:\\data\\db\\clientdb"
  journal:
    enabled: true
sharding:
  clusterRole: "shardsvr"
net:
  bindIp: 192.168.1.112
  port: 27019
replication:
  replSetName: "rs1"

Below are the commands which i have used for zone wise sharding as per the mongodb documentation(official):

rs.initiate({_id: "rs0",members: [{ _id : 0, host : "192.168.1.113:27019" }]}) //for shard1
rs.initiate({_id: "rs1",members: [{ _id : 1, host : "192.168.1.112:27019" }]}) //for shard2

sh.addShard("rs0/192.168.1.113:27019"); //Adding shard1 from mongos client
sh.addShard("rs1/192.168.1.112:27019"); //Adding shard2 from mongos client
sh.addShardToZone("rs0","IND");
sh.addShardToZone("rs1","UK");
sh.addTagRange("testdb.user", {zipcode: "380001"}, {zipcode: "390000"}, 
"IND");
sh.addTagRange("testdb.user", {zipcode: "400000"}, {zipcode: "600000"}, 
"UK");
sh.shardCollection("testdb.user", { zipcode: 1 } );

Please help me get this resolve.

Thanks in Advance.

  • 1
    Can you include your config file? – LowlyDBA May 3 '18 at 14:05
  • @AnkitJani, As your error shown that "NoShardingEnabled". Did you check that you config server is running or not . – Md Haidar Ali Khan May 3 '18 at 17:58
  • @LowlyDBA, I have added all the config files which i have used for the implementation of zone wise sharding and also added commands which i have used for the same. – Ankit Jani May 4 '18 at 6:13
  • @MdHaidarAliKhan, Yes I have checked that, config servers are running properly. – Ankit Jani May 4 '18 at 6:37
2

Problem here is your replSetName: parameters.

BOTH config servers must be at same replica set, f.ex. conf and then those shards (data nodes) both should have different replica set names. f.ex. rs0 and rs1.

Now your config1 is rs0 and config2 is rs1.

  • Thanks @JJussi This is for replicating the data within both the servers but I am trying the example for GDPR where I dont need to replicate the data across the Shards. I want to do data distribution not the replication using zone sharding. – Ankit Jani May 4 '18 at 13:35
  • It looks like that you don't understand how clustering (sharding) works. ;-) Config server(s) are common to ALL shards. Config server must be replica set (replica set can be one node or multiple node replica set). Single shard can be single node, single node replica set or multiple node replica set. After that you have one or more mongoS services to where clients connect. – JJussi May 4 '18 at 17:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.