Mongo Database Maintenance¶
Enabling Database Maintenance Functionality¶
run mongo-related tests locally with Regolith, thus allowing you to update Regolith’s mongo-interoperability with confidence,
run the “Regolith fs-to-mongo” command to move whole collections to your server and,
run the “Regolith mongo-to-fs” command to save collections from your server in the json format
These downloads are a multistep process, so follow carefully
Go to https://docs.mongodb.com/manual/administration/install-community/ and download the community server as a service for your relevant operating system. At the time of writing, this is a link to version 4.4.6.
If you are a windows user, please see the additional notes below.
In order for all Regolith-Mongo functionality to work locally on windows, you must ensure that you have either installed the mongodb server as a service, or that you start the service before running mongo maintenance commands in Regolith.
For certain operating systems and methods of download, both the server and the tools will be downloaded simultaneously (macOS and Ubuntu at the time of writing). If that is not the case (windows users), be sure to also download the tools from the following link https://www.mongodb.com/try/download/database-tools?tck=docs_databasetools.
You will likely be provided an option to download “Compass”. Compass is the desktop GUI application to interface visually with local and remote mongo servers. It doesn’t hurt to have this as a maintainer, however, none of our current maintenance practices utilize it.
Windows users must go through the additional step of adding the mongo executables to their environment path variable manually. In order to do so, search “Path” in your windows search bar. You should be presented with an “Edit the System and Environment Variables” control panel link. After following this link, press “environment variables”, “path” under user variables, “Edit…” under user variables, “new” in the resulting window, to add two new directories to the path variable. These directories will take the forms “C:\Program Files\MongoDB\Server\<e.g. 4.4>\bin” and “C:\Program Files\MongoDB\Tools\<e.g. 100>\bin”
Setting Up a Server¶
LOCAL
REMOTE
Uploading Additional Collections to the Cluster¶
Create a directory called rg-db-mongo-port
In this directory, create the following folder structure (projecta.yml is inside of db as an example)
+---db
| projecta.yml
|
\---local
regolithrc.json
Structure your regolithrc.json file in the following way, with <databaseName> filled in with the name of the database on the cluster that you intend to upload the yaml files to. Note that the database name must be replaced both in the name and dst_url keys
{"groupname": "Billinge Group",
"databases": [
{"name": "<databaseName>",
"dst_url": "mongodb+srv://uname_from_config:pwd_from_config@<clusterName>.uc5ro.mongodb.net/<databaseName>?w=majority",
"url": "..",
"public": false,
"path": "db",
"local": true,
"backend": "mongodb"}
]
}
Add all of the collections that you would like to upload to mongo in the form of yaml or json files in the db directory
Ensure that your user.json file contains a valid userID and password in the ‘mongo_id’ and ‘mongo_db_password’ keys
From the local directory, activate your regolith environment (by entering “conda activate <regolithEnvName>” in the terminal)
Still in the local directory, now with the regolith environment active, enter the following into the terminal “regolith fs-to-mongo”