Connect a database from a self deployed MongoDB Community Edition
This guide will take you through all the neccessary steps needed to connect a database from a self deployed replica set MongoDB Community Edition instance to Florentine.ai:
Create a readonly user
Start by connecting to your database via MongoDB shell. You might have to modify the command, i.e. add your own host and/or a different port, see Connect to a Deployment in the MongoDB docs in case you need help:
mongosh --host localhost --port 27017
Switch to the database you want to connect to Florentine.ai. Replace <db_name>
with your actual database name:
use <db_name>
Run the following command to create a read-only user. Replace <db_name>
with your actual database name, <db_username>
with a username (i.e. florentine
) and <db_password>
with a strong password:
db.createUser({
user: "<db_username>",
pwd: "<db_password>",
roles: [{ role: "read", db: "<db_name>" }]
})
If you have not yet configured your MongoDB instance to use authorization: enabled
you must add it to your mongod.conf
files on ALL replicas:
security:
authorization: enabled
Then restart all mongod processes:
DANGER
Please note that all services connecting to the database without authentication will start failing. Make sure that you create an admin user before restarting and check that all other services use proper authentication before restarting.
Please see Use SCRAM to Authenticate Clients on Self-Managed Deployments in the MongoDB docs for more information.
sudo systemctl restart mongod
Grant network access
Besides a user with database access Florentine.ai needs network access as well. You need to add the Floretine.ai IPs 167.99.246.57
and 209.38.238.253
to bindIp
to your mongod.conf
files on ALL replicas:
net:
bindIp: 127.0.0.1,167.99.246.57,209.38.238.253
Restart all mongod processes:
sudo systemctl restart mongod
Please note
Depending on your setup you might as well need to configure your firewall settings to allow the Florentine.ai IPs 167.99.246.57
and 209.38.238.253
.
Create the connection string
You should now be able to create the connection string you need to add in your Florentine.ai account. The structure of the connection string looks like this:
mongodb://<db_username>:<db_password>@<rs1domain>:<port>,<rs2domain>:<port>,<rs3domain>:<port>/<db_name>
Now you need to replace <db_username>
, <db_password>
and <db_name>
with your settings.
Also you need to replace the domain(s) and port(s) with your replica set members (<rs1domain>:<port>
,<rs2domain>:<port>
and so on).
All replica set members must be added and separated by a ,
so in case you have 3 replica set members your final connection string should look comparable to this:
mongodb://florentine:[email protected]:27017,rs2.florentine.ai:27017,rs3.florentine.ai:27017/samples
Enter your final connection string on the connect page in your Florentine.ai account, click on Connect
and if everything is configured correct you should see a list of the collections inside your database.