1

I am new to MongoDB. I am trying to deploy a MongoDB cluster. I am following:

https://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/

I initiated Config Server Replica Set and after that I tried to addShard but I receive always error:

mongos> sh.addShard("rs1/10.1.10.12:27017,10.1.10.13:27017,10.1.10.14:27017")
{
 "ok" : 0,
 "errmsg" : "could not find host matching read preference { mode: \"primary\" } for set rs1",
 "code" : 133
}

I have tried to add a shard but I receive the following error:

mongos> sh.addShard("firstRS/centos-m-1.ovm:27017")
{
 "ok" : 0,
 "errmsg" : "Cannot add firstRS/centos-m-1.ovm:27017 as a shard since it is part of a config server replica set",
 "code" : 96
}

In replicaSet I see:

rs.conf()
{
 "_id" : "firstRS",
 "version" : 3,
 "configsvr" : true,
 "protocolVersion" : NumberLong(1),
 "members" : [
 {
 "_id" : 0,
 "host" : "centos-m-1.ovm:27017",
 "arbiterOnly" : false,
 "buildIndexes" : true,
 "hidden" : false,
 "priority" : 1,
 "tags" : {
 },
 "slaveDelay" : NumberLong(0),
 "votes" : 1
 },
 {
 "_id" : 1,
 "host" : "centos-m-2.ovm:27017",
 "arbiterOnly" : false,
 "buildIndexes" : true,
 "hidden" : false,
 "priority" : 1,
 "tags" : {
 },
 "slaveDelay" : NumberLong(0),
 "votes" : 1
 },
 {
 "_id" : 2,
 "host" : "centos-m-3.ovm:27017",
 "arbiterOnly" : false,
 "buildIndexes" : true,
 "hidden" : false,
 "priority" : 1,
 "tags" : {
 },
 "slaveDelay" : NumberLong(0),
 "votes" : 1
 }
 ],
 "settings" : {
 "chainingAllowed" : true,
 "heartbeatIntervalMillis" : 2000,
 "heartbeatTimeoutSecs" : 10,
 "electionTimeoutMillis" : 10000,
 "getLastErrorModes" : {
 },
 "getLastErrorDefaults" : {
 "w" : 1,
 "wtimeout" : 0
 },
 "replicaSetId" : ObjectId("572e55c00408eaa72066cef3")
 }
}

I cannot understand. Could you help me?

MongoDB shell version: 3.2.6
connecting to: 10.1.10.12:28017/test
mongos> rs.status()
{
 "info" : "mongos",
 "ok" : 0,
 "errmsg" : "replSetGetStatus is not supported through mongos"
}

If I connect to config server and I give: rs.status() I found all nodes with one node highlighted as PRIMARY. After than I try to connect to a mongos instances and I try to add a shard:

sh.addShard( "rs1/10.1.10.14:28017" )

and I get error I reported previously and in log I found:

2016年05月06日T12:37:33.787Z W NETWORK [conn1] No primary detected for set rs1
2016年05月06日T12:37:33.787Z I NETWORK [conn1] All nodes for set rs1 are down. This has happened for 1 checks in a row. Polling will stop after 29 more failed checks

Paul White
95.3k30 gold badges439 silver badges689 bronze badges
asked May 4, 2016 at 17:16
1
  • Were you able to work out the issue? The error messages relate to the replica set rs1 that you are trying to add (apparently rs1 did not have a primary when you tried to add?). If your config server is called firstRS, you should make sure the mongos is started up with a command line similar to: mongos --configdb firstRS/<cfgsvr1:port1>,<cfgsvr2:port2>,<cfgsvr3:port3> Commented May 11, 2016 at 19:13

1 Answer 1

-3

creat three replica set with different port number and then try

answered May 12, 2016 at 12:46
1
  • and then try ... what exactly? Commented May 13, 2016 at 15:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.