Following the MongoDB Sharding Documentation, I start a mongos using a configuration file with the specifics of my config server.
It seems rather straightforward, yet I am running into an issue. I start mongos on one machine (lets say its ip address is "some_ip"):
$ sudo mongos --config /etc/some_config.conf
And I try connecting to its shell from another machine, but I get connection refused error.
$ mongos some_ip:xxxxx
Here's part of my some_config.conf file:
net:
port: xxxxx
bindIp: 0.0.0.0
sharding:
configDB: <configReplSet>/<ip_of_config>:27019
I'm using 0.0.0.0 for testing purposes. I made sure that the ip_addr and port I'm connecting to matches the ip of the host for the mongos and the port I specified in the net.port
param. I also opened up this port in my firewall for ingress/ egress connections.
Did I miss anything ? (NOTE: ** I edited post for further clarification)
UPDATE
(note: i replaced the actual ip addr with "ip_of_config")
This is what my log file for my mongos says when I start mongos.
2018-05-02T05:57:48.533+0000 W NETWORK [monitoring keys for HMAC] Failed to
connect to <ip_of_config>:27019, in(checking socket for error after poll), reason:
Connection refused
2018-05-02T05:57:48.533+0000 W NETWORK [monitoring keys for HMAC] Unable to
reach primary for set crs0
Now my config server is up and running fine, but its log file shows that it accepts multiple connections from my mongos server, but these connections close almost immediately. Also there are a few warning logs:
W SHARDING [Balancer] Balancer settings could not be loaded and will be
retried in 10 seconds :: caused by :: ReadConcernMajorityNotAvailableYet:
Failed to refresh the balancer settings due to
ReadConcernMajorityNotAvailableYet: Read concern majority reads are currently
not possible.
W SHARDING [shard registry reload] cant reload ShardRegistry :: caused by ::
CallbackCanceled: Callback canceled
Best Answer
mongos for “MongoDB Shard,” is a routing service for MongoDB shard configurations that processes queries from the application layer, and determines the location of this data in the sharded cluster, in order to complete these operations. From the perspective of the application, a mongos instance behaves identically to any other MongoDB instance.
As you have mention here mongos.conf file
As here i would like to say that here as you are bindIp in mongos.conf file with 0.0.0.0 but in sharding section , you are using with port number 27019 of any replica set.
Note : As here I am not able to see any logpath destion in your mongos.conf file.
As per MongoDB BOL documentation here Starting in MongoDB 3.6, mongos bind to localhost (
127.0.0.1
) by default.Did you try with this configuration of your
mongos.conf
file.