MongoDB27 Jul 2010 09:43 am

It’s pretty straight forward to setup a Master/Slave configuration for MongoDB. If you want to experiment on a single Windows box, use the steps below:

Start by creating the data directories:

c:\Users\John> cd c:\data
c:\data>mkdir masterdb
c:\data>mkdir slavedb1
c:\data>mkdir slavedb2

Startup the master database (I assume you’ve of course added Mongo’s bin directory to your path).

c:\>mongod --master --dbpath c:\data\mongodb

Startup the first slave. Make sure to change its port from something other than the default 27017 that’s being used by the master db! The source is the server name where master resides.

c:\>mongod --slave --port 27018 --source localhost --dbpath c:\data\slavedb1

The other slaves may be setup the same way.

c:\>mongod --slave --port 27019 --source localhost --dbpath c:\data\slavedb2
c:\>mongod --slave --port 27020 --source localhost --dbpath c:\data\slavedb3

To confirm that that replication is working, connect to the master.

c:\>mongo localhost/MongoTunes
>db.Artists.insert({ Name : "Radiohead" })

Now connect to one of the slaves.

c:\>mongo localhost:27019/MongoTunes
> db.Artists.find()
{ "_id" : ObjectId("4c4eef2b84610000000035f6"), "Name" : "Radiohead" }

You should see the Artist document you inserted in the master. If you don’t, run the find again… If you’ve setup a few slaves, there might be a delay.

More advanced configuration is available at http://www.mongodb.org/display/DOCS/Master+Slave

MongoDB & NoRM23 Jul 2010 12:26 pm

MongoDB & NoSQL & MapReduce17 Jul 2010 05:50 pm

IronPython & CodeVoyeur & MVC06 Jul 2010 05:27 pm

NoRM & NoSQL06 Jul 2010 09:01 am

Hosting23 Jun 2010 07:12 pm

MVC & MongoDB & NoRM14 Jun 2010 04:29 pm

CodeVoyeur & MongoDB & NoRM28 May 2010 08:07 pm

Python & IronPython & MongoDB27 May 2010 04:22 pm

CodeVoyeur10 May 2010 06:49 pm

Next Page »