123 lines
3.7 KiB
Markdown
123 lines
3.7 KiB
Markdown
|
# 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
|
||
|
|
||
|
1. Install [Virtual Box](https://www.virtualbox.org/).
|
||
|
2. Install [Vagrant](https://www.vagrantup.com/).
|
||
|
3. [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
|
||
|
|
||
|
1. `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
|
||
|
|
||
|
1. `vagrant suspend`
|
||
|
|
||
|
This will suspend the VM, retaining all data.
|
||
|
|
||
|
## To Reset
|
||
|
|
||
|
1. `vagrant destroy`
|
||
|
2. `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:
|
||
|
|
||
|
1. `vagrant ssh`
|
||
|
|
||
|
## Restarting MongoDB
|
||
|
|
||
|
### Checking mongo is not working
|
||
|
|
||
|
Once Vagrant is working
|
||
|
|
||
|
1. `ps -a` or `ps -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
|
||
|
|
||
|
1. `more /vagrant/mongo/initdb.sh` or go to your MongoDB initdb.sh file
|
||
|
2. 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 starting `mongod`.
|
||
|
3. 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 &`
|
||
|
4. `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: <empty>
|
||
|
* 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: <empty>
|
||
|
|
||
|
Note: It defaults to MDB due to the Authentication database setting above.
|