Login into MongoDB
anastasiamac edited this page Jan 9, 2017
·
9 revisions
Pages 44
- Home
- API best practices
- Azure provider design implementation notes
- Blocking bugs
- Bootstrap Internals (WIP)
- Boring Techniques
- Bug fixes and patching
- CI Tests
- Code Review Checklists
- Containers
- Creating New Repos
- Debugging Juju
- Debugging Juju Misc Topics Pointers
- Debugging Races
- Diagnosing MongoDB Performance
- Faster LXD
- Feature Documentation
- Getting Mongo dump
- Guidelines for writing workers
- Hacking upload tools
- howto: implement effective config structs
- Implementing environment providers
- Incomplete Transactions and MgoPurge
- Interactive Commands
- Intermittent failures
- Juju Logging
- Juju Scripts
- Juju Storage (WIP)
- Juju User Documentation
- KVM instance creation
- Login into MongoDB
- Managing complexity
- mgo txn example
- MgoPurgeTool
- Misc Topics
- Mongo Issues
- MongoDB and Consistency
- pprof facility
- Reviewboard Tips and Tricks
- Stop Start Machine Agent
- Stress Test
- Triaging Bugs
- Update Launchpad Dependency
- Writing Unit Tests
- Show 29 more pages…
Navigation
Testing
Releases
Documentation
Development
- READ BEFORE CODING
- Blocking bugs process
- Bug fixes and patching
- Contributing
- Code Review Checklists
- Creating New Repos
-
MongoDB and Consistency
- [mgo/txn Example] (https://github.com/juju/juju/wiki/mgo-txn-example)
- Scripts
- Update Launchpad Dependency
- Writing workers
- Reviewboard Tips
Debugging and QA
- Debugging Juju
- [Faster LXD] (https://github.com/juju/juju/wiki/Faster-LXD)
Clone this wiki locally
Script (Juju 2.0 only)
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"Manually
Get the MongoDB password by running:
$ sudo grep statepassword /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2On 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 admin -p "<password>" --sslAllowInvalidCertificates --ssl --authenticationDatabase adminFor older Juju versions where MongoDB 2 is in use, install mongodb-clients:
sudo apt-get install mongodb-clientsThen log in to the shell like this:
mongo 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --username admin --password "<password>"For Juju 1.x
Use oldpassword instead of statepassword in scripts and commands above.