mongoDB for sysadmins

Post on 12-May-2015

982 views 0 download

description

Quick intro to mongoDB for sysadmins. With a simple vagrant demo

Transcript of mongoDB for sysadmins

mongoDB for sysadmins

Jordi Soucheiron - @jordixouSoftware developer & sysadmin @ DEXMA

@sudoersbcn 2013/6/4

What is mongoDBDocument oriented noSQL database

Auto sharding -> scales horizontally

Auto replication -> high availability

Atomic in-place updates

No transaction support

JSON queries and results

Open source with commercial support by 10gen

What is it used for?Storing files

Storing logs

Queue systems

Data mining

Basic mongoDB setup

Pros: Simple

Cons: No sharding, no high-availability

Small mongoDB setup

Pros: High-availability, optional delayed node

Cons: No sharding

Advanced mongoDB setup

Advanced mongoDB setupPros:

High-availabilityReads and writes are distributed amongst all

nodesYou choose what kind of replication you wantYou choose what collections are shardedYou choose the sharding key

Cons:More complexity than the other solutionsYou ALWAYS want 3 config servers

Demo time

Configure VagrantInit Vagrant:

Modify Vagrantfile:Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.provision :puppet do |puppet| puppet.manifests_path = "manifests" puppet.manifest_file = "init.pp" endend

vmvagrant init precise64 http://files.vagrantup.com/precise64.box

Configure Puppetmkdir Manifests

vi init.pp:

package { 'mongodb':ensure => present,

}

Start Vagrant and mongoDB

vagrant up

vagrant ssh

sudo /etc/init.d/mongodb stop

mkdir –p ~/mongo/db1 ~/mongo/db2 ~/mongo/db3

mongod --port 27017 --dbpath ~/mongo/db1 --replSet rs0 --smallfiles --oplogSize 128 --rest

mongod --port 27018 --dbpath ~/mongo/db2 --replSet rs0 --smallfiles --oplogSize 128

mongod --port 27019 --dbpath ~/mongo/db3 --replSet rs0 --smallfiles --oplogSize 128

Add nodes to the replica set

mongo --port 27017

rsconf = { _id: "rs0", members: [ { _id: 0, host: "127.0.0.1:27017" } ] }rs.initiate( rsconf )rs.add("127.0.0.1:27018")rs.add("127.0.0.1:27019")

Questions