I am trying to deploy mongodb sharding. I have deployed a replica set in three machines. However, I still can't seem to make it work when I try to sh.addShard("test/mongodb1.example.net:27017")
to all the three nodes. The error shown is:
2016-11-09T16:02:46.704+0800 W NETWORK [conn105] No primary detected for set team3
Another error:
{
"ok" : 0,
"errmsg" : "could not find host matching read preference { mode: \"primary\" } for set test",
"code" : 133
}
1) Set up initial replica set for each node (This works fine)
a) Run these for all 3 nodes:
mkdir /temp/data/team3
./mongod --replSet "team3" --dbpath /temp/data/team3
./mongo --host <mongodb[x].example.net>
b) Primary node runs:
rs.initiate()
rs.add("mongodb2.example.net")
rs.add("mongodb3.example.net")
2) Setting up configuration server and query router for Three replica cluster (This works fine)
Primary node runs:
mkdir /temp/data/config_rs
./mongod --configsvr --replSet "config_rs" --dbpath /temp/data/config_rs
./mongo --host mongodb1.example.net --port 27019
3) Add shards (Problem with adding shard)
Primary node runs:
sh.addShard("mongodb1.example.net")
sh.addShard("mongodb2.example.net")
sh.addShard("mongodb3.example.net")