Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't use localhost as a shard since all shards need to communicate. either use all shards and configdbs in localhost or all in actual IPs host

Tags:

mongodb

mongos> sh.addShard("rs0/delhivery-tech:27017,delhivery-tech:27018,delhivery-tech:27019");

{
    "ok" : 0,
    "errmsg" : "can't use localhost as a shard since all shards need to communicate. either use all shards and configdbs in localhost or all in actual IPs  host: delhivery-tech:27017 isLocalHost:0"
}

I am running 3 instances on same host with different port. It is a testing system. I created a replica set named rs0. Now I am adding shard. It shows the instances are running on localhost. Even I tried with the ip and loopback ip also..

It would be great if anybody help me out from the same

like image 980
Amit Avatar asked Feb 12 '23 07:02

Amit


1 Answers

I think you have used "localhost" when you have registered your config server ( --configdb ). Can you be sure you start your mongos with hostname? Something like

mongos --configdb delhivery-tech:27019

I invite you to look at the first paragraph in this page: http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/

PS: When you have issue with your cluster (replica set and/or shard) it is a good thing to show the status/configuration of it. ( rs.status() or sh.status() ). This will help the people to understand your topology and give better answer.

like image 77
Tug Grall Avatar answered Feb 14 '23 19:02

Tug Grall