This lab is specifically targeted for Nightscout users with a single website and Mongo database hosted on Azure.
There have been numerous outages with Azure-hosted Mongolab servers. Migrating your database away from Azure should reduce your Nightscout downtime. The lab will walk you through the steps to migrate your Mongo database from Azure to another provider such as Amazon or Rackspace.
To migrate your Mongo database, you will need to make the following changes
- Clone your existing Azure-hosted Mongo database to a Mongolab server hosted by another cloud provider
- Change your Azure website configuration to use the new Mongo URI
- Change your uploader app configuration to use the new Mongo URI
Step 1 – Clone your existing Mongo database
- Login to your Mongolab.com account.
- Click the button labeled “Clone Existing” to clone your Mongo database
- Choose your Mongo database from the drop down list under “Select a Mongolab Database”
- Choose a cloud provider such as Amazon Web Services or Rackspace
- Choose a cloud provider location close to you offering the “Single-node” plan
- Choose the plan called “Sandbox” listed under “Single-node”
- Enter the name of your new database
- Click “Create new MongoDB deployment”
- Your database and collections have been migrated, however you still need to create a new database user and password. Click on your new database from the Mongolab home page. Click the link labeled “Click here” to create a database user.
- In the pop-up window, enter a database username and password, and then click Create. You can use the username and password from your previous database, or create a different username and password. In either case, make sure you write the username and password down.
- After creating your database user, near the top of the page you should see the text “To connect using a driver via the standard URI.” Below that text will be a generic URI for your database.
You will need to write down the URI, substituting your username and password for the text <dbuser>:<dbpassword>. Based on the screen shot above, the URI would be:
Step 2 – Change your Azure website configuration to use your new database.
- Login to the Azure Management Portal at http://manage.windowsazure.com
- Click on your website name, then click the “Configure” button just above the graph
- Scroll down to the section called “Connection Strings” then click the link to “Show Connection Strings.”
- Find the variable called “mongo” or “MONGO_CONNECTION”. This is your Mongo URI. Copy your existing Mongo URI to a text file as backup. Change the value to the new Mongo URI for your new database created in Step 1.
- Press the “SAVE” button at the bottom of the screen to save your website changes
Step 3 – Change your Nightscout uploader app to use your new Mongo database URI.
This step is ONLY required if you are using Mongodb upload. If you are using REST API upload, you do not need to perform this step.
- Open your Nightscout app, tap the three dots, and then tap Preferences.
- Tap “Mongodb”, then tap “URI”
- Enter your new Mongo database URI and press Ok.
- Exit out of the app preferences.
- Disconnect your uploader phone from your Dexcom receiver.
- Either “Force Close” the app from your phone’s Settings / Apps page, or reboot your uploader phone.
- Reconnect your Dexcom receiver to your uploader phone.
- Verify all uploader app icons are green, and the uploader graph shows current Dexcom data.
- Verify your website shows current Dexcom data.
- If your website shows a white screen after changing your website configuration, you have probably mis-typed your new Mongo URI in your Azure website configuration. Double check that A) The new Mongo URI you wrote down at the end of Step 1 (cloning your database) is correct and B) You correctly entered the new Mongo URI in your website’s “mongo” or “MONGO_CONNECTION” variable.
- If your website shows old data but no new data, you have probably mis-typed your new Mongo URI in your uploader app. Double check that the new Mongo URI entered in your uploader app exactly matches what is entered in your website configuration.
- If your uploader app shows a red “Upload” icon, you probably have mis-typed your new Mongo URI in your uploader app. Double check that the new Mongo URI entered in your uploader app exactly matches what is entered in your website configuration.
- If all else fails, ask for help or revert to your previous Mongo database and URI until you have time to troubleshoot.