Charmed MongoDB 5 Tutorial - Deploy MongoDB

Deploy MongoDB

This page is part of the tutorial Deploy a MongoDB replica set.

Deploy

To deploy Charmed MongoDB, all you need to do is run the following command:

juju deploy mongodb --channel=6/beta

Juju will fetch the charm from Charmhub and begin deploying it to the LXD cloud. This process can take several minutes depending on how provisioned (RAM, CPU,etc) your machine is.

Track status

You can check the status of your deployment by running:

juju status --watch 1s --relations

This will display a table with an overview of all the status info of the elements in your juju model, like IP addresses, ports, state, and other useful data. The --watch 1s flag means that it will update every 1s.

For this tutorial, it is recommended to have a separate terminal permanently set to juju status --watch 1s --relations so that you can see what is happening every time you make changes to your juju model. The --relations flag will display additional information regarding integrations (previously known as “relations”), which will be useful later on.

When your MongoDB application is ready, juju status --watch 1s will show:

Model     Controller  Cloud/Region         Version  SLA          Timestamp
tutorial  overlord    localhost/localhost  3.1.6   unsupported  11:24:30Z

App      Version  Status  Scale  Charm    Channel   Rev  Exposed  Message
mongodb           active      1  mongodb  5/edge   96  no

Unit        Workload  Agent  Machine  Public address  Ports      Message
mongodb/0*  active    idle   0        10.23.62.156    27017/tcp

Machine  State    Address       Inst id        Series  AZ  Message
0        started  10.23.62.156  juju-d35d30-0  jammy       Running

To exit the screen with juju status --watch 1s, enter Ctrl + C.

Next step: Access MongoDB

Hi Followed all the steps , still i get authentication error I also was looking at the below command that is running the mongodb once deployment is successful. the mongod.conf is empty, don’t know where all configurations are set /snap/charmed-mongodb/80/usr/bin/mongod --config /var/snap/charmed-mongodb/80/etc/mongod/mongod.conf --bind_ip_all --replSet=mongodb --dbpath=/var/snap/charmed-mongodb/common/var/lib/mongodb --auth --clusterAuthMode=keyFile --keyFile=/var/snap/charmed-mongodb/current/etc/mongod/keyFile

is it a chroot , wheneve i change the files it always says permission exceptions

1 Like

Hi @chalicham thank you so much for your time and for reporting this error! We really appreciate it. The authorization issue occurred because the username was incorrect in the tutorial.

(DB_USERNAME in tutorial was not updated to reflect the latest changes in the code) and now the tutorial is fully functional. For your reference the fix we implemented: changed DB_USERNAME=“admin” to DB_USERNAME=“operator”

1 Like