.. | ||
mongo | ||
README.md | ||
Vagrantfile |
Summary
This directory contains scripts for starting a VM running MongoDB, configured in a similar way to the one on the real servers. This readme contains various sections that should be read and understood to start and stop the server.
The sections are:
- Connection Information: The connection details for the database that is created
- Setup: Steps required for setup
- Maintenance: How to bring mongo up again if the VM wasn't suspended properly
- Robo3T connection setup guide: How to connect to the MongoDB using Robo3T
Note, the information on connecting a local server to the MongoDB is contained in the top-level README.md.
Connection information:
- ip address:
172.16.0.20
(machine local only) - username/password:
mdbadmin
/abc123
(full control) - Authentication Database:
MDB
(case sensitive) - SSL: Enabled
- SSL Keys:
path/to/bridge-local-dev/mongodb/mongo/keys/mongodb.pem
(generated on first run)
There is also a root user on the admin
database as admin
/abc123
.
Setup
Pre-requisites
- Install Virtual Box.
- Install Vagrant.
- [Optional] Download a copy of the dev server database to devdump/dump using mongodump.
WARNING: delete the
SystemLog
backup as they always seem to fail to restore.
To Start
vagrant up
from the shell/console
The first time, This will create and start an entirely new VM, download and install all packages, etc. After that, this will only start up the suspended VM again.
NOTE: if the PC is rebooted without suspending the VM, the VM will be "powered down" and will not
have mongodb running next time it is resumed with mongo up
. See Maintenance section below for
how to bring MongoDB up again.
To Stop
vagrant suspend
This will suspend the VM, retaining all data.
To Reset
vagrant destroy
vagrant up
This will entirely reset the VM, losing all previous data. You have been warned!
Maintenance
Login to the VM from the host using:
vagrant ssh
Restarting MongoDB
Checking mongo is not working
Once Vagrant is working
ps -a
orps -ax
- You will be able to find a line similar to: "mongod --port: xxx ... " If there is no line, then mongo isn't running.
Starting mongo again
more /vagrant/mongo/initdb.sh
or go to your MongoDB initdb.sh file- Copy the last line starting
mongod
printed in your terminal, if you run the line. If you opened the file, copy the last line of the file startingmongod
. - Sudo the line, it should look something like:
sudo mongod --port 27017 --dbpath /var/lib/mongodb/ --smallfiles --oplogSize 128 --sslMode requireSSL --sslPEMKeyFile /vagrant/mongo/keys/mongodb.pem &
ps -a
- mongo should appear running now
Robo3T connection setup guide
Basic setup info to get a connection working through Mongo3T.
Create a new Connection with the following configuration:
Connection Tab
- Type: Direct Connection
- Name: Local Dev
- Address: 172.16.0.20
- Port: 27017
Authentication Tab
- Perform authentication: TRUE
- Database: MDB
- User Name: mdbadmin
- Auth Mechanism: SCRAM-SHA-1
SSH Tab
- Use SSH tunnel: FALSE
SSL Tab
- Use SSL protocol: TRUE
- Authentication Method: Self-signed Certificate
- Use PEM Cert./Key: TRUE
- PEM Certificate/Key: path/to/bridge-local-dev/mongodb/mongo/keys/mongodb.pem [1]
- Passphrase:
- Ask for passphrase each time: FALSE
- Advanced Options: FALSE
[1]: MongoDB as configured doesn't verify the CA of the client cert provided, so actually any pem file will do, but this is an easy one to get.
Advanced Tab
- Default Database:
Note: It defaults to MDB due to the Authentication database setting above.