This repository provides a Vagrantfile, Dockerfile and a bootstrap script to create MongoDB Cluster using a virtual machine built on Virtualbox software hypervisor. After setup is complete shared MongoDB sharded cluster on a single virtual machine running on your local machine.
MongoDB cluster consisted of the following docker containers
- mongos1-3r1-3: Mongod server with three replica sets distributes on six mongo containers.
- configservers1-3: Stores metadata for sharded cluster distributed on three mongo containers.
- mongos1: Mongo routing service installed on one mongo container.
- skydock: Used for service discovery and inserts internal docker images records into skydns.
- skydns: Used as internal DNS for containers.
There unfortunately some hard-coded timeouts due to timing issues with MongoDB.
Install Virtualbox based off the installation instructions.
First, install Homebrew.
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Install VirtualBox and Vagrant using Brew Cask.
brew tap phinze/homebrew-cask
brew install brew-cask
brew cask install virtualbox
brew cask install vagrant
git clone [email protected]:jacksoncage/mongo-docker.git
cd mongo-docker
vagrant up
This will pull all the images from Docker index and setup Mongodb sharded cluster.
vagrant ssh
./docker/start_cluster.sh"
You should now be able connect to mongos1 and the new sharded cluster:
MongoDB Cluster is now ready to use
Connect to cluster by:
$ mongo --port 49550
To re-initiate cluster run start_cluster.sh
again. To rebuild vagrant vagrant destroy
and then vagrant up
Data is stored at ./docker_mongodb_cluster/mongodata/
and are excluded from version control. Data will be persistent even for a vagrant destroy
as it's mounted into vagrant and then needed container as well. To remove all data rm -rf ./docker_mongodb_cluster/mongodata/*