jonahhill / mongo-docker

Instant MongoDB Cluster Environment based on docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instant MongoDB sharded cluster

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.

Unfortunately there are some hard coded timeouts due to timing issues with MongoDB.

Installation:

Linux

Install Virtualbox based off the installation instructions.

MacOS

Install Homebrew

First, install Homebrew.

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Install Virtualbox and Vagrant

Install VirtualBox and Vagrant using Brew Cask.

brew tap phinze/homebrew-cask
brew install brew-cask
brew cask install virtualbox
brew cask install vagrant

Check out the repository

git clone git@github.com:jacksoncage/mongo-docker.git
cd mongo-docker
vagrant up

Setup Cluster

This will pull all the images from Docker index and setup Mongodb sharded cluster. Please make sure DOCKERIP in docker_mongodb_cluster/start_cluster.sh is using docker0 interface or public IP if you prefer that.

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

Kill/restart cluster

To re-initiate cluster run start_cluster.sh again. To rebuild vagrant vagrant destroy and then vagrant up

Persistent storage

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/*

Issues

  • Shard folders - shared folder may not work at some system with certain vagrant and virtualbox version (this issue is not fixed until now), so users may need to use some other ways to upload .sh and .js files in docker_mongodb_cluster/mongo/js

Built upon

About

Instant MongoDB Cluster Environment based on docker


Languages

Language:Shell 80.9%Language:JavaScript 19.1%