I want to access MongoDB inside a Volume Block Storage via MongoDB Compass to manage my production database.
Below is my volume list
nguyenquangtri@Nguyens-Mac-mini ~ % doctl compute volume list
ID Name Size Region Filesystem Type Filesystem Label Droplet IDs Tags
fb61a5fb-c586-11ee-8cf4-0a58ac14a3ab pvc-0c11ec25-ed80-4113-bf84-9b6ef03780f7 1 GiB sgp1 ext4 [399862184] k8s:f5f9b710-cf3b-4071-93e5-87aadb5ce09a
fc3a2990-c586-11ee-a9f0-0a58ac14a476 pvc-8dc047a6-07a9-4604-a654-6c441305c626 1 GiB sgp1 ext4 [399862182] k8s:f5f9b710-cf3b-4071-93e5-87aadb5ce09a
f9ba7163-c586-11ee-8cf4-0a58ac14a3ab pvc-f865999f-7f33-44ec-8a3b-ecdc20f17427 1 GiB sgp1 ext4 [399862183] k8s:f5f9b710-cf3b-4071-93e5-87aadb5ce09a
fd664b83-c586-11ee-a4ec-0a58ac14a32f pvc-ff2592bf-9330-49e9-95aa-495d8db620d2 1 GiB sgp1 ext4 [399862182] k8s:f5f9b710-cf3b-4071-93e5-87aadb5ce09a
So how can I do that?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
To access MongoDB hosted on a Volume Block Storage via MongoDB Compass, you need to ensure that MongoDB is correctly set up and accessible over the network, and your Volume is attached to a specific Droplet in DigitalOcean.
From your
doctl
volume list, it seems you have your volumes set up and attached to Droplets.The volumes you’ve listed are using
ext4
, which is a filesystem type. For MongoDB to run on these volumes, you must have MongoDB installed on a Droplet that has access to these volumes. Make sure MongoDB data directories are correctly set to use the mounted volume paths.By default, MongoDB binds to
localhost
(127.0.0.1). To access it remotely (e.g., via MongoDB Compass), you need to edit the MongoDB configuration file (mongod.conf
) to listen on an external interface. You can do this by setting thebindIp
option undernet
to0.0.0.0
(to listen on all interfaces) or to the specific IP address of your Droplet’s network interface.Example:
Warning: Exposing MongoDB to the internet can pose significant security risks. Ensure you secure MongoDB access using authentication and firewall rules.
Here is a step by step tutorial on how to usually configure this:
Before proceeding, it’s crucial to secure your MongoDB instance:
mongod.conf
to enablesecurity.authorization
.27017
) to known IP addresses. Use DigitalOcean’s Cloud Firewall service to restrict access to your Droplet’s MongoDB port.Once your MongoDB has been configured for remote access, you can connect using Compass as normal:
An alternative option here is to use a Managed MongoDB cluster instead which will simplify the operational side of things for you:
Hope that this helps!
Best,
Bobby