Giter Club home page Giter Club logo

vagrant-mongodb's Introduction

Vagrant plugin and puppet manifests for MongoDB

Creates (by default) 8 virtual machines based on Ubuntu Lucid (64bits).

  • 1x ReplicaSet (primary, secondary, arbiter) without authentication.
  • 1x ReplicaSet (primary, secondary, arbiter) with authentication.
  • 1x Standalone server without authentication.
  • 1x Standalone server with authentication.

The ReplicaSet servers will have their /etc/hosts synchronized among them.

All servers will retrieve and install the latest MongoDB from the official 10gen repository.

Several new Vagrant configurations are available in the Vagrantfile to configure a MongoDB replicaset, such as the servers priority to become primaries.

A new Vagrant comand is availalbe to initialize the replicaset based on the configuration in the Vagrantfile, and to create users for authenticated setup.

Usage

$ git clone https://github.com/bjori/vagrant-mongodb.git
$ cd vagrant-mongodb

Boot up all servers

$ vagrant up # Will bootup *all 8 servers*

Or only bootup a normal ReplicaSet

$ vagrant up primary secondary tertiary # Will bootup only one ReplicaSet

To bootup ReplicaSet with authentication enabled

$ vagrant up primaryauth secondaryauth tertiaryauth # RS with auth

Don't want ReplicaSets? This will create a standalone MongoDB server

$ vagrant up standalone # Will bootup the standalone server

And this will create a standalone MongoDB server with authentication enabled

$ vagrant up standaloneauth # Standalone with auth

Initializing ReplicaSets

To initialize the ReplicaSet for the first time, type

$ vagrant mongo primary --init-replicaset

and/or

$ vagrant mongo primaryauth --init-replicaset

To initialize the ReplicaSet for the authenticated environment.

Creating users

To create a first time admin user on a standalone server run

$ vagrant mongo standaloneauth -c -u adm -p pass --db admin

or for ReplicaSet environment

$ vagrant mongo primaryauth -c -u adm -p pass --db admin

To create more users you have to authenticate using that admin user

$ vagrant mongo standaloneauth -c -u user -p mypass --db mydb --authuser adm --authpass pass --authdb admin

/etc/hosts

The ReplicaSets are configured using the hostnames defined in the Vagrantfile. I recommend you add all these hosts to your local /etc/hosts (the servers themselves already have).

By default the following hostnames and IPs are used

172.16.1.10 primaryauth.rs.local primaryauth
172.16.1.11 secondaryauth.rs.local secondaryauth
172.16.1.12 tertiaryauth.rs.local tertiaryauth
172.16.2.10 standaloneauth.local standaloneauth

172.16.3.10 primary.rs.local primary
172.16.3.11 secondary.rs.local secondary
172.16.3.12 tertiary.rs.local tertiary
172.16.4.10 standalone.local standalone

Thats it folks!

And there we go! Now you have a full MongoDB replicaset running in its own virtualized network, and all of the servers are running on the default ports. To connect to MongoDB, just fire up your favorite driver and connect :)

Fixing my mess?

This is the first time I have ever created a puppet module, puppet manifest, vagrant plugin or written Ruby code at all. There is very likely something could have been done better or prettier. I would love it if you forked this repo and applied your skillz cleaning things up.

Everything should work out of the box though :)

TODO

  • MongoDB Sharded environment
  • mongobride support
    • vagrant mongo command to tune mongobridge
    • Configuration settings
  • Split the vagrant mongo command to simplify creating users
  • Automatically initialize ReplicaSets when all RS vms have booted up

vagrant-mongodb's People

Contributors

bjori avatar

Watchers

James Cloos avatar xebitstudios avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.