MongoDB on Azure

The MongoDB Replica Set Azure wrapper is currently a preview release. Please provide feedback, mongodb-dev, mongodb-user and IRC #mongodb are good places!

The MongoDB Wrapper for Azure allows you to deploy and run a MongoDB replica set on Windows Azure. Replica set members are run as Azure worker role instances. MongoDB data files are stored in an Azure Blob mounted as a cloud drive. One can use any MongoDB driver to connect to the MongoDB server instance. The MongoDB C# driver v1.3.1 is included as part of the package.

Getting the package

The MongoDB Azure Wrapper is delivered as a Visual Studio 2010 solution with associated source files. The simplest way to get the package is by downloading it from GitHub. It is recommended using the latest tagged version.

Alternatively, you can clone the repository run the following commands from a git bash shell:

$ cd <parentdirectory>
$ git config --global core.autocrlf true
$ git clone git@github.com:mongodb/mongo-azure.git
$ cd mongo-azure
$ git config core.autocrlf true

You must set the global setting for core.autocrlf to true before cloning the repository. After you clone the repository, we recommend you set the local setting for core.autocrlf to true (as shown above) so that future changes to the global setting for core.autocrlf do not affect this repository. If you then want to change your global setting for core.autocrlf to false run:

$ git config --global core.autocrlf false

Components

Once you have unzipped the package or cloned the repository, you will see the following directories:

  • SampleApplications - This directory contains sample applications that run against MongoDB on Azure. More information can be found in the README
  • ReplicaSets - This directory contains the bare MongoDB Replica Set worker role code. Use this if you are familiar with Azure and are ready to build your own application on top of MongoDB running on Azure

Initial Setup

Run the appropriate *setup.cmd to setup up the solution for building. The script only needs to be run once. The script does the following:

  • Creates ServiceConfiguration.Cloud.cscfg as a copy of configfiles/ServiceConfiguration.Cloud.cscfg.ref
  • Downloads the MongoDB binaries (currently 2.1.0-pre) to the appropriate solution location

Building

The prerequisites can be found in the Github readme

Once these are installed, you can open MongoAzure.sln from Visual Studio and build the solution.

Deploying and Running

Running locally on compute/storage emulator

The following instructions are for running the sample application

To start, you can test out your setup locally on you development machine. The default configuration has 3 replica set members running on ports 27017, 27018 and 27019 with a replica set name of 'rs'

In Visual Studio run the solution using F5 or Debug->Start Debugging. This will start up the replica set and the MvcMovie sample application.

You can verify this by using the MvcMovie application on the browser or by running mongo.exe against the running instances.

Deploying to Azure

Once you have the application running locally, you can deploy the sample app solution to Windows Azure. Note You cannot execute locally against storage in Azure due to the use of Windows Azure Drive.

  • Detailed configuration options are outlined here
  • Step-by-step deployment instructions are here

Additional Information

The azure package wraps and runs mongod.exe with the following mongod command line options:

--dbpath --port --logpath --journal --nohttpinterface --logappend --replSet

MongoDB 2.1.0-pre is currently used in this package.

MongoDB creates the following containers and blobs on Azure storage:

  • Mongo Data Blob Container Name - mongoddatadrive(replica set name)
  • Mongo Data Blob Name - mongoddblob(instance id).vhd

FAQ/Troubleshooting

  • Can I run mongo.exe to connect?
    • Yes if you set up remote desktop. Then you can connect to the any of the worker role instances and run e:\approot\MongoDBBinaries\bin\mongo.exe.
  • Role instances do not start on deploy to Azure
    • Check if the storage URLs have been specified correctly.

Known issues/Where do I file bugs?

https://jira.mongodb.org/browse/AZURE


Labels

nosql nosql Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus