Trouble Connect Query Router to Config Server in MongoDB Sharding - mongodb

I'm working on my project to Create a Sharded Cluster in MongoDB using Microsoft Azure Ubuntu 14.01 Virtual Machine.
I'm using 3 config server, 2 query router, and 4 shard server.
I already install MongoDB on all those server with version 2.6.9. Then i set up all of the configs server and they worked, they're listening. But when i started to configure the query router instances, it didn't want to connect to the configs server. Here is the command that i use:
mongos --configdb config0.example.com:27019,config1.example.com:27019,config2.example.com:27019
Here is one of the error message that appear after i run the command.
Couldn't check dbhash on config server [hostname]:27019 :: caused by :: 11002 socket exception [CONNECT_ERROR] server [[hostname]:27019] connection pool error: couldn't connect to server [hostname]:27019 (23.97.57.219), connection attempt failed.
Is there any solution of this problem? Really appreciate your help.

Related

Connect to mongodb via ssh tunnel failing

I have tried to connect to my mongodb on a server i own via an ssh tunnel via the following apps but nothing will connect:
compass
robomongo
nosqlbooster4mongo
phpstorm inbuilt mongodb java connector
Server and mongo:
Server: ubuntu 18lts
Mongo: latest community version
The Connection URL in all instances is the same (also tried removing the query params) and this url works on the node app:
mongodb://localhost:27017/data-aggregator?retryWrites=true&w=majority
nosqlbooster4mongo's error message is:
But the connection url is 27017 and gets changed to 37903 for some reason
PHPStorm's error message is:
DBMS: Mongo DB Case sensitivity: plain=mixed, delimited=mixed Driver:
MongoDB JDBC Driver (ver. 1.13, JDBC4.2) Effective version: UNKNOWN
(ver. 0.0) Ping: 10 sec, 289 ms (keep-alive query results in error)
Timed out after 10000 ms while waiting to connect. Client view of
cluster state is {type=UNKNOWN, servers=[{address=localhost:42865,
type=UNKNOWN, state=CONNECTING,
exception={com.mongodb.MongoSocketReadException: Exception receiving
message}, caused by {java.net.SocketException: Connection reset}}].
Nothing works but i cannot understand why.
The SSH connection is working as confirmed by nosqlbooster4mongo and phpstorm
But as soon as it then tries to connect to the local mongodb instance it fails. I don't know if this is an issue with the SSH tunnel or the mongo setup. Via a terminal i can connect to mongo no issue, also the node app there can too.
The tunnels are using the same key as i use to connect to the server via terminal without issue which leads me to believe it is mongo but i don't know where to look :/
As the tunnel is established, then this says the server firewalls are not an issue.
I don't know what it is, is there an additional query param for ssh tunnel access?
Solved by #Jack_Woehr on: https://www.mongodb.com/community/forums/t/mongo-5-community-edition-cannot-connect-via-tunnel/151526
The trick was to not use the ssh tunnel from any of the tools listed and just create a the tunnel on the OS.

Unable to connect to mongodb on remote server

I have a spring boot application with a mongo database on localhost and everything work fine.
Now i want to deploy my application to my server and the database is on another remote server.
I changed mongod.conf file and uncommented “bindIp: 0.0.0.0 #default value is 127.0.0.1”
In my application.properties file i have this:
“spring.data.mongodb.uri=mongodb://172.16.4.26:27017/jenkinsdb”
When i run my application i get “com.mongodb.MongoSocketOpenException: Exception opening socket” caused by “Caused by: java.net.SocketTimeoutException: connect timed out”
It seems like MongoDB is not accessible over a network there might be several reasons. I have listed some:
MongoDB port 27017 is not open
Firewall is blocking the connection with another machine
You can also try adding the authentication information in your URI like this:
spring.data.mongodb.uri=mongodb://user:secret#mongo1.example.com:12345,mongo2.example.com:23456/test
OR
you can split it over multiple properties
spring.data.mongodb.host=mongoserver.example.com
spring.data.mongodb.port=27017
spring.data.mongodb.database=test
spring.data.mongodb.username=user
spring.data.mongodb.password=secret
If you want to check whether there is a problem with the application or MongoDB you can spin up the free Mongo Atlas instance and try to connect that with your application if that works then there will be surely a connectivity issue with our machine

Problem to connect mongo DB replica set from linux, single instance run ok. Using .net core mongo driver

I am trying to connect an application in .net core from a linux machine to a mongo replicaset. But I am getting a timeout error.
Unhandled exception. System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector
The replica ips are accessible from this machine, a response is obtained by pinging.
If in linux the connection to mongo is to a single instance of the replica, it works correctly.
This same code in windows connects without problem.
If you are certain IP connectivity works, most likely you have the hostnames wrong. The hostnames used in RS config must work from each client.
See https://github.com/p-mongo/mongodb-faq.

set up Apache2 virtual hosts and now MongoDB connection refused

I'm running Ubuntu 14.04 on an AWS EC2 instance with Apache2. This morning I upgraded my Apache2 settings to allow multiple virtual servers following these instructions: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Just now I tried to access my MongoDB instance, but I cannot do it either through the PHP MongoDB driver or through the shell. I get this error when attempting to connect with a PHP MongoClient():
Failed to connect to: localhost:27017: Connection refused'
and I get this error when trying to run the mongo shell:
2015-06-03T19:23:57.307+0000 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-06-03T19:23:57.308+0000 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
Everything was running fine just last night, and I haven't directly modified MongoDB settings. What can I do to fix this? How do Apache2 settings relate to MongoDB? I've been trying to look through the MongoDB docs, but I don't see anything that looks relevant.
You need to setup Security Group for your EC2 instance. And allow Inbound connection for the mongodb port, in your case 27017.
When I went through the logs, I saw a message that there was insufficient room for "journal file." I rebooted my AMI on an EC2 instance with more storage and reinstalled Mongo. That did the trick. I had uploaded a few files to the instance after updating my Apache2 settings, so those few more files must have pushed the instance past what Mongo could tolerate. Too bad the error message wasn't more helpful, but I should have checked the logs sooner. It would also be nice if the logs had a more explicit message.

mongodb could not connect to server

I'm new to MongoDB. I'm trying to connect to my remote mongo database from my work machine( I tried for both mongohq as well as mongolab). I'm getting the error listed below. When I run the same command from my home machine it runs fine and does connect to remove mongo database. I'm not sure what is messed up on my work machine but I'd like to fix it. Thanks for you help.
MongoDB shell version: 2.4.9
connecting to: linus.mongohq.com:10097/mydb
Thu Jan 16 04:16:02.689 Error: couldn't connect to server linus.mongohq.com:10097
at src/mongo/shell/mongo.js:147
exception: connect failed
As per question comments, your mongo shell client can't connect to the mongo instance. Assuming that your internet connectivity is fine, the most common reason for the failure is that the ports are blocked on your network.
Some ISPs automatically block these ports by default as an additional security protection for users that don't need them open. Contact your ISP or network admin, they should be able to help you out.