17
mongodb debian
rainbow napkin edited this page 2025-05-21 02:53:36 +00:00
| title |
|---|
| Prepping MongoDB for use with Canopy |
Step-by-step procedure for prepping MongoDB for use with Canopy:
MongoDB, while gratis and open-source, is not entirely FLOSS. If you're hell bent on using software with a hard FLOSS license, you're probably better off FerretDB
Install MongoDB
- Install curl, assuming you haven't already
sudo apt install curl - Import public key for mongo repo
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor - Add mongodb sources to apt sources.list.d
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list - Tell apt to update repo's and install mongosh other preq-reqs
sudo apt update && sudo apt install mongodb-org
Hardening MongoDB
This section is incomplete, I'd like to go over this with more security-related documentation for MongoDB. I'm not a professional DBA XP
- Start mongod without authentication and drop into a shell
sudo systemctl start mongod & mongosh - Switch over to the admin database
use admin - Create the administrative user:
db.createUser(
{
user: "admin",
pwd: passwordPrompt(),
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }
]
}
)
- Add the following to
/etc/mongod.confto enable authentication:
security:
authorization: enabled
Setting up the Canopy User/DB
- Restart
mongodwithsudo systemctl restart mongod - Drop back into
mongoshwith authenticationmongosh -u 'admin', entering the password on prompt - Switch over to the canopy database
use canopy - Create the canopy user:
db.createUser(
{
user: "canopy",
pwd: passwordPrompt(),
roles: ["readWrite"]
}
)
The database is now prepared to serve an instance of canopy! Feel free to continue with the setup.