I have a expressjs applications deployed on EC2 VMs and use a Mongo DB in separate VM, and I am trying to find which VMs currently have open connections to the Mongo DB.
Is there away (or interface) to list the IP addresses of the currently opened MongoDB Connections ?
Thanks!
According to https://jira.mongodb.org/browse/SERVER-5085 the one method is:
db.currentOp(true)
Related
I created an AWS Document DB in the same region as my EC2. When I try to connect to it using the command provided by AWS the terminal seems to get stuck.
The ec2 and Document DB are in the same region.
Document DB's security group allows 27017 access.
Both are in the same VPC.
I don't understand why it says connected but then doesn't allow me to enter commands
asds_asds
You can check your working process from here https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-ec2.html to see if you missed something.
I've removed localhost in network connections from a MongoDB Atlas project.
Now my mongo shell can't connect to the MongoDB collection. Other than adding localhost back to network connections, is there any other way to connect to a MongoDB collection? I'd like to poke around the production database sometimes from the CLI, is this possible?
You can use VPC peering to connect.
I manage connection to mongodb in mongolab. But today, I can't find the option to add a new remote connection. There's only option to create mongodb deployments in their own environment.
How can I add new remote connections?
Thanks
Let's say I have two server droplets in digitalocean, but I only want to use the mongodb of the 1st server. How can I connect the 2nd server to the 1st server's mongodb?
What would be the mongourl that i should set on the 2nd server upon deployment?
Thanks in advance!
MONGO_URL=mongodb://12.34.56.78:27017/db_name
Where 12.34.56.78:27017 is the MongoDB droplet's IP and port, and db_name is a custom database name ("meteor" by default).
I can determine the current number of connections by
db.serverStatus().connections
but all that gives me is the current number of connections. Is there anywhay to determine which ips are connected and which connection number they have been assigned to?
From mongo shell, this will print client IP:port, along with connection ID:
db.currentOp(true).inprog.forEach(function(d){if(d.client)print(d.client, d.connectionId)})
Note: passing true to db.currentOp() shows all connections (including idle). The docs have more examples on filtering connections, see:
db.currentOp reference and currentOp output fileds with descriptions.
From mongo shell run db.currentOp() to show all active connections or db.currentOp(true) to show all connections.
It depends on your db engine, but one simple way you can do it with netstat, checking the port your database allows to connect, and if you have security concerns you can limit the ip addresses that connect in the configuration file. Most databases by default only allow localhost to connect to them.