Skip to content

Instantly share code, notes, and snippets.

@freyes
Forked from niedbalski/mongo.sh
Last active March 27, 2024 18:25
Show Gist options
  • Save freyes/0828055f1eef3b423a36999d451b8411 to your computer and use it in GitHub Desktop.
Save freyes/0828055f1eef3b423a36999d451b8411 to your computer and use it in GitHub Desktop.
Connect to Juju 2.0 Mongodb
# valid for juju 2.0
# see https://bugs.launchpad.net/ubuntu/+source/juju-mongodb3.2/+bug/1583740
$ juju ssh -m controller 0
# when running a Xenial controller
/usr/lib/juju/mongo3.2/bin/mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
# when running a Bionic controller
mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') --eval 'db = db.getSiblingDB("juju"); db.system.profile.find().sort( { millis : -1 } ).pretty();' localhost:37017/admin | tee system.profile.log
#
# When using juju-db from a snap (e.g. Focal controller).
#
juju-db.mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment