-2

I am trying to initiate a mongo shards replica set from mongos server, I want my mongos to maintain replica set and able to add new server to replication if needed.

1 Answers1

0

If you are trying to add a new shard to an existing cluster, you need to first create the replica set for the shard. As at MongoDB 3.6, you cannot run replica set management commands such as rs.initiate() or rs.add() via mongos: these commands need to be sent to the current primary for the replica set.

Once a new shard is successfully added to a deployment, the sharded cluster balancer will automatically take care of redistributing sharded collections to factor in the availability of the additional shard.

Stennie
  • 1,250
  • 7
  • 12
  • i just want to deploy normal mongo shards and i want to make them as a replica from running command 0n mongos , is this possible? – siva nagi reddy Mar 16 '18 at 06:27
  • @sivanagireddy What you are asking for is not possible. A new shard replica set has to be configured and initiated via the primary `mongod` for the replica set before adding as a new shard via `mongos`. – Stennie Mar 16 '18 at 06:55
  • sharding is not possible ok, can we initiate a replica set from monos, I mean take an ex(3 mongo and 1 mongos) I want to 3 mongo servers as the replica and I want to do that from mongos server. – siva nagi reddy Mar 16 '18 at 15:48
  • @sivanagireddy The scenario is the same with or without sharded databases: if you want to initiate a replica set you need to do so via `mongod`, not a `mongos`. The `rs.initiate()` command needs to be sent directly to the intended primary. Once you have initiated a replica set, you can use [`sh.addShard()`](https://docs.mongodb.com/manual/reference/method/sh.addShard/) via a `mongos` to add this replica set to a sharded deployment. – Stennie Mar 16 '18 at 21:00