I am trying to setup a mongodb sharded setup using the bitnami helm chart. I just tried to set the rootPassword but it seem the server no longer starts. In the config server, I see
{"t":{"$date":"2022-10-23T10:44:04.360+00:00"},"s":"I", "c":"NETWORK", "id":4712102, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"Host failed in replica set","attr":{"replicaSet":"mongo-mongodb-sharded-shard-0","host":"mongo-mongodb-sharded-shard0-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017","error":{"code":6,"codeName":"HostUnreachable","errmsg":"Error connecting to mongo-mongodb-sharded-shard0-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017 :: caused by :: Could not find address for mongo-mongodb-sharded-shard0-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017: SocketException: Host not found (authoritative)"},"action":{"dropConnections":true,"requestImmediateCheck":false,"outcome":{"host":"mongo-mongodb-sharded-shard0-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017","success":false,"errorMessage":"HostUnreachable: Error connecting to mongo-mongodb-sharded-shard0-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017 :: caused by :: Could not find address for mongo-mongodb-sharded-shard0-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017: SocketException: Host not found (authoritative)"}}}}
{"t":{"$date":"2022-10-23T10:44:04.361+00:00"},"s":"I", "c":"-", "id":4333222, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM received error response","attr":{"host":"mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017","error":"HostUnreachable: Error connecting to mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017 :: caused by :: Could not find address for mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017: SocketException: Host not found (authoritative)","replicaSet":"mongo-mongodb-sharded-shard-1","response":{}}}
{"t":{"$date":"2022-10-23T10:44:04.361+00:00"},"s":"I", "c":"NETWORK", "id":4712102, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"Host failed in replica set","attr":{"replicaSet":"mongo-mongodb-sharded-shard-1","host":"mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017","error":{"code":6,"codeName":"HostUnreachable","errmsg":"Error connecting to mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017 :: caused by :: Could not find address for mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017: SocketException: Host not found (authoritative)"},"action":{"dropConnections":true,"requestImmediateCheck":false,"outcome":{"host":"mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017","success":false,"errorMessage":"HostUnreachable: Error connecting to mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017 :: caused by :: Could not find address for mongo-mongodb-sharded-shard1-data-0.mongo-mongodb-sharded-headless.default.svc.cluster.local:27017: SocketException: Host not found (authoritative)"}}}}
Then I try to look at the shards:
mongodb 10:44:47.02 INFO ==> Trying to connect to MongoDB server mongo-mongodb-sharded...
timeout reached before the port went into state "inuse"
And the sharded mongos
│ mongodb 10:44:42.82 INFO ==> Trying to connect to MongoDB server mongo-mongodb-sharded-configsvr-0.mongo-mongodb-sharded-headless.default.svc.cluster.lo │
│ mongodb 10:44:42.83 INFO ==> Found MongoDB server listening at mongo-mongodb-sharded-configsvr-0.mongo-mongodb-sharded-headless.default.svc.cluster.loca │
│ MongoServerError: Authentication failed. │
│ MongoServerError: Authentication failed. │
Seem like the sharded mongos is down because theres an auth error? But why?
My Chart.yaml
apiVersion: v2
name: experiment-mongo-sharding
description:
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- name: mongodb-sharded
version: 6.0.2
repository: https://charts.bitnami.com/bitnami
values.yaml
mongodb-sharded:
auth:
rootUser: root
rootPassword: password
replicaSetKey: somesecret
Whats wrong here?
Also, once its up, how do I connect to it?
Related
I'm using homebrew to initialize mongodb as it follows:
brew services start mongodb-community#5.0
It starts successfully
==> Successfully started mongodb-community (label: homebrew.mxcl.mongodb-community)
However, when I type mongoto run mongodb, I keep getting connection refused:
MongoDB shell version v5.0.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:372:17
#(connect):2:6
exception: connect failed
exiting with code 1
So I typed brew services list to check if the mongoDB is up, and it seems it started with an error status:
Name
Status
User
Plist
mongodb-community
error
guilhermemendes
/opt/homebrew/opt/mongodb-community/...
check the following.
if you are using M1 based MacOS then install mongo db (and brew) with Rosetta.
check the IP binding on mongo config
(/usr/local/etc/mongod.conf or /opt/homebrew/etc/mongod.conf)
verify the connection string URI format - Mongo docs - connection-string-uri-format
I'm trying to connect mongo shell with my mongo atlas M0 cluster and ending up getting this error
Error Message
Solution I tried which didnt work:
I upgraded the monog version to 4.2 to be insync with mongo version in
atlas, didnt solve the problem getting this error mongo
"mongodb://cluster0-shard-00-02.79t7i.azure.mongodb.net:27017,cluster0-shard-00-00.79t7i.azure.mongodb.net:27017,cluster0-shard-00-01.79t7i.azure.mongodb.net:27017/testdatabase?tls=true"
MongoDB shell version v4.2.8 connecting to:
mongodb://cluster0-shard-00-02.79t7i.azure.mongodb.net:27017,cluster0-shard-00-00.79t7i.azure.mongodb.net:27017,cluster0-shard-00-01.79t7i.azure.mongodb.net:27017/testdatabase?compressors=disabled&gssapiServiceName=mongodb&tls=true
*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
2020-08-16T00:14:57.693+0545 E QUERY [js] Error: couldn't connect
to server cluster0-shard-00-01.79t7i.azure.mongodb.net:27017,
connection attempt failed: HostUnreachable: Connection reset by peer :
connect#src/mongo/shell/mongo.js:341:17 #(connect):2:6
2020-08-16T00:14:57.695+0545 F - [main] exception: connect
failed 2020-08-16T00:14:57.695+0545 E - [main] exiting with
code 1
On trying with mgo go driver i'm getting the error as:
time="2020-08-17T15:32:32+05:45" level=debug msg="mongo host and port
:
mongodb://cluster0-shard-00-00.akidp.azure.mongodb.net:27017,cluster0-shard-00-01.akidp.azure.mongodb.net:27017,cluster0-shard-00-02.akidp.azure.mongodb.net:27017"
time="2020-08-17T15:33:32+05:45" level=error msg="Unable to connect to
mongo no reachable servers" panic: runtime error: invalid memory
address or nil pointer dereference [signal SIGSEGV: segmentation
violation code=0x1 addr=0x0 pc=0x8f3a02]
goroutine 1 [running]: gopkg.in/mgo%2ev2.(*Session).Copy(0x0,
0x7fbebca1b008)
/home/sgupta/go/pkg/mod/gopkg.in/mgo.v2#v2.0.0-20180705113604-9856a29383ce/session.go:1593
+0x22 github.optum.com/claredi/oti.git/ds.Copy(0xc001ae3a30, 0x0, 0x0) /home/sgupta/go/src/github.optum.com/claredi/oti.git/ds/ds.go:166
+0x3c github.optum.com/claredi/oti.git/ds/announcements.indexes() /home/sgupta/go/src/github.optum.com/claredi/oti.git/ds/announcements/announcements.go:47
+0xff github.optum.com/claredi/oti.git/ds.Init(0xc0000f8000, 0xc0001efe68)
/home/sgupta/go/src/github.optum.com/claredi/oti.git/ds/ds.go:98
+0x52e main.startAPIServer(0x0, 0xc000098360) /home/sgupta/go/src/github.optum.com/claredi/oti.git/api/main.go:83
+0xe98 main.main() /home/sgupta/go/src/github.optum.com/claredi/oti.git/api/main.go:26
+0x4d exit status 2
Hoping to get a resolution from the experts. Thanks in Advance :)
First, in Atlas:
Ensure the cluster itself looks healthy in "Clusters"
Go to "Network Access" and ensure your IP is allowed
Just to be safe, go to "Database Access" and create a new user with proper permissions
If your problem is similar to Cannot connect to mongodb atlas through mongo shell, it might be that your IP changed or something, and you need to allow your current IP.
hello can anybody help me with this error
$ mongo "mongodb+srv://cluster0-zdzwa.mongodb.net/test" --username admin-dalia
MongoDB shell version v4.2.6
Enter password: Cannot get console mode 6
connecting to: mongodb://cluster0-shard-00-02-zdzwa.mongodb.net:27017,cluster0-shard-00-00-zdzwa.mongodb.net:27017,cluster0-shard-00-01-zdzwa.mongodb.net:27017/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2020-05-01T18:00:58.985+0300 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-02-zdzwa.mongodb.net:27017,cluster0-shard-00-00-zdzwa.mongodb.net:27017,cluster0-shard-00-01-zdzwa.mongodb.net:27017
2020-05-01T18:00:58.986+0300 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-02-zdzwa.mongodb.net:27017
2020-05-01T18:00:58.986+0300 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-01-zdzwa.mongodb.net:27017
2020-05-01T18:00:58.986+0300 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-00-zdzwa.mongodb.net:27017
2020-05-01T18:00:59.983+0300 I NETWORK [ReplicaSetMonitor-TaskExecutor] Confirmed replica set for Cluster0-shard-0 is Cluster0-shard-0/cluster0-shard-00-00-zdzwa.mongodb.net:27017,cluster0-shard-00-01-zdzwa.mongodb.net:27017,cluster0-shard-00-02-zdzwa.mongodb.net:27017
2020-05-01T18:01:00.530+0300 I NETWORK [js] Marking host cluster0-shard-00-01-zdzwa.mongodb.net:27017 as failed :: caused by :: Location40659: can't connect to new replica set master [cluster0-shard-00-01-zdzwa.mongodb.net:27017], err: AuthenticationFailed: Missing expected field "pwd"
It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
2020-05-01T18:01:00.530+0300 E QUERY [js] Error: can't connect to new replica set master [cluster0-shard-00-01-zdzwa.mongodb.net:27017], err: AuthenticationFailed: Missing expected field "pwd" :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
----------
2020-05-01T18:01:00.533+0300 F - [main] exception: connect failed
2020-05-01T18:01:00.533+0300 E - [main] exiting with code 1
thanks in advance
You need to add your IP to whitelist.
In your mongoAtlas there is a tab securicy -> network access -> add there 0.0.0.0
This will allow access from any IP from web.
If you look at the error it looks like you didn't or can't enter your password.
$ mongo "mongodb+srv://cluster0-zdzwa.mongodb.net/test" --username admin-dalia
MongoDB shell version v4.2.6
Enter password: Cannot get console mode 6
The error from Atlas is:
err: AuthenticationFailed: Missing expected field "pwd"
pwd is a short name for password.
Try passing it in with the --password argument.
You might also try Compass which allows you to paste the connection string straight into the tool as a way to validate that you are doing the right thing.
I have Robo 3T-1.3 installed on my ubuntu 16.4 LTS.
It is showing me the following error:
`Cannot connect to the MongoDB at localhost:27017.
Error:
Network is unreachable. Reason: couldn't connect to server localhost:27017, connection attempt failed: SocketException: Error connecting to localhost:27017 (127.0.0.1:27017) :: caused by :: Connection refused`
How to solve it?
Firstly check your mongo status via this command.
sudo systemctl status mongod
OR
You can follow this link.
https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04
Trying to start mongo node with command
mongos --configdb 192.168.6.3:27019 --port 27018
In results having output:
Tue Mar 15 16:08:21.062 [mongosMain] warning: couldn't check dbhash on config server 192.168.6.3:27019 :: caused by :: 11002 socket exception [CONNECT_ERROR] server [192.168.6.3:27019] mongos connectionpool error: couldn't connect to server 192.168.6.3:27019
Tue Mar 15 16:08:21.064 [mongosMain] ERROR: error upgrading config database to v4 :: caused by :: could not load config version for upgrade :: caused by :: 11002 socket exception [CONNECT_ERROR] server [192.168.6.3:27019] mongos connectionpool error: couldn't connect to server 192.168.6.3:27019
Tue Mar 15 16:08:21.064 warning: couldn't check dbhash on config server 192.168.6.3:27019 :: caused by :: 11002 socket exception [CONNECT_ERROR] server [192.168.6.3:27019] mongos connectionpool error: couldn't connect to server 192.168.6.3:27019
Could you help me, what I'm doing wrong?
I would summarize solution from the comments to close the question.
First, read the mongo server logs.
If you see DNS-related errors there then check if you use correct DNS names which your system can resolve. To exclude DNS errors try to run server using direct IP addresses in configurtaion.
If you still see network-related errors (such as could not connect to server) then check:
the server instance you are trying to connect to is running
you use correct IP address and port
your network links are up
firewalls both on peer and your side are not blocking connection