问题
I'm trying to learn some MongoDB and want to mount a two sharded DB for distributing my data between these two "nodes" and take advantage of its efficiency and robustness.
I'm also working over Docker. So in docker I created 4 VMs with their respective IPs:
- mongo1(172.17.0.6): first db to use as shard
- mongo2(172.17.0.5): second db to use as shard
- mongocfg(172.17.0.4): a config image for the whole system
- mongorouter(172.17.0.3): the router to access both other shards; the whole db
If you're not familiarized with docker just think of it like a VirtualBox manager who helps running multiple virtual images under the same environment and OS. For instance, just think every IPs up there are just different computers.
The thing is that to add a new shard, I've read that I need to connect to mongorouter and then add both shards by their IP and port. In docker, I execute $ docker exec -it mongorouter mongo
and the mongo console appears as
mongos>
and there I type and get exactly:
mongos> sh.addShard("172.17.0.6:27017")
{ "ok" : 0, "errmsg" : "No common protocol found.", "code" : 126 }
And I've tried to look what does that mean and haven't got any clue. It's not just simple googling as I thought myself. Of course the shard is not added after this. In a deseperate shot I've tried all of the IPs, even with the Gateway for all of them 172.17.0.2
.
I could use some advice just with the correct documentation like where to find the error code 126 or what protocol is the errmsg referring or anything.
Thanks in advance.
EDIT.
I didn't found the solution. The problem was because I was using an incorrect Dockerfile to build the VM. If anyone is interested, the difference was that the wrong Docker file had a FROM ubuntu:latest
and the correct one had FROM mongo
. If someone get here with the same problem, that's the better direction I could point you.
来源:https://stackoverflow.com/questions/36813359/mongo-addshard-no-common-protocol-found-errmsg-126