-
Notifications
You must be signed in to change notification settings - Fork 494
Login into MongoDB
The following script will SSH to a Juju 2.0 controller machine and start a mongo shell. It optionally takes the machine to connect to and the model name (defaulting to machine "0" in the model named "controller"). Use juju switch
first to ensure the desired controller is selected.
#!/bin/bash
machine=${1:-0}
model=${2:-controller}
read -d '' -r cmds <<'EOF'
conf=/var/lib/juju/agents/machine-*/agent.conf
user=`sudo grep tag $conf | cut -d' ' -f2`
password=`sudo grep statepassword $conf | cut -d' ' -f2`
/usr/lib/juju/mongo*/bin/mongo 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --username "$user" --password "$password"
EOF
juju ssh -m $model $machine "$cmds"
Get the MongoDB password by running:
$ sudo grep statepassword /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2
On xenial, juju-mongodb3.2 should include the mongo client, so run it from its installed directory:
/usr/lib/juju/mongo3.2/bin/mongo 127.0.0.1:37017/juju -u "machine-0" -p "<password>" --sslAllowInvalidCertificates --ssl --authenticationDatabase admin
For older Juju versions where MongoDB 2 is in use, install mongodb-clients:
sudo apt-get install mongodb-clients
Then log in to the shell like this:
mongo 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --username admin --password "<password>"
Use oldpassword
instead of statepassword
in scripts and commands above.
Note: Many of these wiki pages are out-of-date. Please refer to the material at discourse.jujucharms.com, especially content within the Development category.
Testing
Releases
Documentation
Development
- READ BEFORE CODING
- Blocking bugs process
- Bug fixes and patching
- Contributing
- Code Review Checklists
- Creating New Repos
- MongoDB and Consistency
- Scripts
- Update Launchpad Dependency
- Writing workers
- Reviewboard Tips
Debugging and QA