Skip to content

Instantly share code, notes, and snippets.

@iboard
Created July 2, 2011 06:38
Show Gist options
  • Save iboard/1059803 to your computer and use it in GitHub Desktop.
Save iboard/1059803 to your computer and use it in GitHub Desktop.
MongoDB 1.8 ReplicaSet Config

This is a sample config I use for CBA on two debian boxes

  • edge.iboard.cc is the "master" where the app is running
  • s1.iboard.cc is the "slave" where mongo is running as a kind of backup

On edge.iboard.cc

/etc/mongodb/mongodb.conf

MONGO_USER="mongod"
MONGO_OPTS="--dbpath /data/mongodb/  --rest --journal --replSet iboard"

On s1.iboard.cc

/etc/mongodb/mongodb.conf

MONGO_USER="mongod"
MONGO_OPTS="--dbpath /data/mongodb/  --rest --journal --replSet iboard"

Now start mongo on both nodes.

I'm using the default /etc/init.d/mongod script to do so.

Initializing the ReplSet on edge.iboard.cc (the master)

devel:/etc/mongodb# /usr/local/mongodb/bin/mongo 
MongoDB shell version: 1.8.2
connecting to: test
> rs.initiate({_id: "iboard", members: [ { _id:0, host: "edge.iboard.cc" }, { _id:1, host: "s1.iboard.cc" } ]})
{
"info" : "Config now saved locally.  Should come online in about a minute.",
"ok" : 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment