Hello,
I am facing an issue when trying to connect to a MongoDB cluster that I deployed using Percona Everest with external access. When trying to connect via Mongo Compass, I get the following error:
`getaddrinfo ENOTFOUND mongodb-dev1-rs0-0.mongodb-dev1-rs0.percona-everest.svc.cluster.local`.
url connection:
mongodb://userAdmin:******@34.0.0.0:27017,35.0.0.0:27017,35.0.0.0:27017/
1 Like
Hi, I have not been able to connect using MongoDB Compass either. I have forwarded this information to my colleagues in the Percona Everest team.
At the moment I’ve been using documentation from Percona Operators to make the connection
Run a container with a MongoDB client and connect its console output to your terminal:
kubectl -n percona-everest run -i --rm --tty percona-client --image=percona/percona-server-mongodb:6.0.9-7 --restart=Never -- bash -il
Connecting using mongosh
mongosh "mongodb://userAdmin:****@host:27017,host:27017,host:27017/admin?ssl=false"
I’ve been told that connecting using MongoDB Compas is so far only available when creating a cluster using Percona Operator directly, with the parameter
spec:
clusterServiceDNSMode: "External"
also the connection will be available with the Direct Connection parameter
However, this cannot be done now with a cluster created in Percona Everest.
We have created a task in Jira to add this in future versions.
Yes. I’m working with an operator. Uh, thank you.
1 Like
Yes, @Slava_Sarzhan helped me with this today, he often helps on the forum, so if there are any questions, we’ll try to help.
1 Like
I was able to connect using MongoDB Compass.
I used a single host in the path and Direct Connection mode.
If one node, it’s easy, but if you have multiple nodes, you need to define Primary.
I used PMM and the ReplicaSet Summary dashboard since so far Everest doesn’t show the status of nodes, but as far as I know this is planned to be added.
A note for the future. How to connect in detail step by step for beginners.
Currently, the Percona Everest interface for a MongoDB cluster with External Access enabled displays the IPs of the hosts to connect to. I believe that we will fix it in the future, it’s about the current moment.
To connect using MongoDB Compass we need a Primary replica, but we don’t know which IP leads to the Primary at the moment.
We can get a list of k8s services, and find out the matching IPs and replica names.
kubectl -n percona-everest get services
Next, we can use mongosh to connect to the cluster:
mongosh "mongodb://databaseAdmin:******@host:27017,host2:27017,host3:27017/admin?ssl=false"
And find out which replica is Primary with the command:
rs.status()
Or a shortened version of the output
rs.status().members.forEach(function(member) {printjson({name: member.name, status: member.stateStr})})
Output:
rs0 [primary] admin> rs.status().members.forEach(function(member) {printjson({name: member.name, status: member.stateStr})})
{
name: 'mongodb-bmq-rs0-0.mongodb-bmq-rs0.percona-everest.svc.cluster.local:27017',
status: 'SECONDARY'
}
{
name: 'mongodb-bmq-rs0-1.mongodb-bmq-rs0.percona-everest.svc.cluster.local:27017',
status: 'PRIMARY'
}
{
name: 'mongodb-bmq-rs0-2.mongodb-bmq-rs0.percona-everest.svc.cluster.local:27017',
status: 'SECONDARY'
}
Here we already understand which replica is Primary (mongodb-bmq-rs0-1) and use its Service IP to connect to MongoDB Compass.
1 Like