mongodb

Vagrant box with Severalnines database cluster deployment scripts

Prerequisites

General

Using Vagrant's Multi-VM environment makes launching several VMs to form a cluster painless and it's easy to quickly start playing with the various database clusters and our Severalnines's ClusterControl in a contained environment.

NOTE: The vagrant box file's size is 390MB and can take some time to download.
(Mar/14): ClusterControl 1.2.5, MySQL Cluster 7.3, Percona XtraDB Cluster 5.6, Codership 5.6, MongoDB 2.4.x
(May/13): MySQL Cluster 7.2.12, Codership Galera 5.5.29(Source distribution, wsrep_23.7.3.r3853), Percona XtraDB Cluster 5.5.30-30.2(Percona Server (GPL), Release 30.2, wsrep_23.7.4.r3843), Mongodb 2.4.x

This vagrant box comes with a set of Severalnines's database cluster deployment scripts to bootstrap the following:

  • 3 node Galera Cluster for MySQL (Codership and Percona builds).
  • 4 node MySQL Cluster. 2 SQL nodes, 2 MGM nodes and 2 Data nodes.
  • 1 sharded MongoDB Cluster with config servers and routers on 3 hosts.

Tags: 

Add MongoDB repo for apt and/or yum (bash)

#!/bin/bash

[ `whoami` != "root" ] && echo "Do: sudo $(basename $0)" && exit 1

install=$1

dist="Unknown"
regex_lsb="Description:[[:space:]]*([^ ]*)"
regex_etc="/etc/(.*)[-_]"

do_lsb () {
lsb=`lsb_release -d`
[[ $lsb =~ $regex_lsb ]] && dist=${BASH_REMATCH[1]} ; return 0
return 1
}

do_release_file () {
etc_files=`ls /etc/*[-_]{release,version} 2>/dev/null`
for file in $etc_files
do
  [[ $file =~ $regex_etc ]] && dist=${BASH_REMATCH[1]} ; break
done
}

if [ `command -v lsb_release` ]
then
  do_lsb
  [ $? -ne 0 ] && do_release_file
else

Tags: 

MongoDB Quick Start - Replica Sets and Sharding

Scaling out 1 node with Replica Set

If you already have a running mongod instance you first need restart it with --replSet

$ mongod --fork --rest --replSet mySetName --port 27017 --dbpath ~/Projects/db/data/mongo/r0 --logpath ~/Library/Logs/mongod-r0.log

Initialize the node via the mongo client

$ mongo
> rs.initiate()
{
        "info" : "Config now saved locally.  Should come online in about a minute.",
        "ok" : 1
}

This node is our Primary Node where read/write is done initially.

> db.messages.insert({City: "Tokyo"})
> db.messages.find()

Tags: 

Subscribe to mongodb