MongoDB cluster deployment

clusteringmongodb

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-06T12:37:33.787Z W NETWORK [conn1] No primary detected for set rs1
2016-05-06T12: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

Best Answer

creat three replica set with different port number and then try