Installing multiple mongoDB versions on the same server

I have installed a 2.4 mongoDB version and I'd like to compare against the recently released 2.6 version.

I want to know if possible to do a clean new install rather en an update to see if those two version can co-exist in the same server.

I'm using Linux red-hat distro at this moment.

thanks.


Take a look at the mlaunch tool by Thomas Rueckstiess. Once you download different versions of the binaries from the download page as suggested in the comments (and put them somewhere that makes sense on your system) you can then use mlaunch to start identical configurations for testing by specifying a different binary path (and data directory, port etc. if running multiple in parallel).

If extra tools are not what you are looking for you can achieve similar results using the internal test commands provided by MongoDB, though please note that these commands are currently considered internal for testing purposes, are not documented, and can be changed (or stop working) at any time (I have tested recently on 2.4 and 2.6 versions and can confirm that they work for those versions as of writing this answer).

For example, if you want to set up a 2 shard cluster, where each shard was a replica set, you could do the following:

// start a shell from the command line, do not connect to a database
./mongo --nodb
// using that shell start a new 2 shard cluster (this will take a while)
cluster = new ShardingTest({shards : 2, rs : true});
// once that is finished, start a new shell and connect to the mongos (leave previous shell running to monitor logs etc.)
./mongo --port 30999
MongoDB shell version: 2.6.0
connecting to: 127.0.0.1:30999/test
mongos>

Repeat and re-use as needed with whatever version you wish, to shut it down, simply Ctrl-C the original shell (where things are hopefully still logging).

Similarly, if you just want a replica set to test with:

// start a shell from the command line, do not connect to a database
./mongo --nodb
var rst = new ReplSetTest({ name: 'testSet', nodes: 3});
rst.startSet();
// this next line can be hard to type with logging scrolling by, so copy & paste is your friend if you have trouble
rst.initiate();
// start a new shell and connect to the set
 ./mongo --port 31000
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:31000/test
testSet:PRIMARY>

These commands can be used to download mongodb rpm and extract the files. After extracting package contents, binary files can be used directly.

yum install yum-plugin-downloadonly
yum install --downloadonly --downloaddir=/tmp mongodb-org-server
mkdir /usr/local/mongo2
cd /usr/local/mongo2
rpm2cpio /tmp/mongodb-org-server-2.6.4-1.x86_64.rpm | cpio -idmv

Now, new mongod can be invoked with:

/usr/local/mongo2/usr/bin/mongod