This is what I want to do:
- Create a Config Server
- Create 2 Shard
- Create a Mongos Router
I don't want to replicate my data using replica set, I want to simulate that each shard has only a part of data like it says is shard theory.
I'm following this guide, but I understood that the guide create many replicas for config server and shared server and I don't want that. So this is what I do:
Config file of Config Server:
sharding: clusterRole: configsvr replication: replSetName: localhost net: bindIp: localhost storage: dbPath: /home/christian/mongo/confsvr/metadata
Execute Config Server:
mongod --config /mongo/confsvr/mongod.conf --port 27019
Now doc uses
rs.initiate() for adding a replica of config server (if I understood right), so I dropped this part.
After that, I created two config file for Shard Server.
sharding: clusterRole: shardsvr replication: replSetName: localhost net: bindIp: localhost storage: dbPath: /home/christian/mongo/shard[1|2]
I started two shard:
mongod --config mongo/shard[1|2]/shard.conf --port 2703[1|2]
Created conf file for Mongos Router:
sharding: configDB:localhost/localhost:27019 net: bindIp: localhost
So i tried to start mongos:
mongos --config /home/christian/mongo/router/mongos.conf
But terminal print in loop this:
Unable to reach primary for set localhost
Cannot Reach any nodes for set localhost
Last steps were connecting to mongos, and add the Shards to DB
How could I obtain what I want?