Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BibMartin/8fc7ae2f9f3996845f2f to your computer and use it in GitHub Desktop.
Save BibMartin/8fc7ae2f9f3996845f2f to your computer and use it in GitHub Desktop.
How to install several mongo shards on a single machine

Inspired by this article

In this tutorial, my IP machine is 192.168.1.65 ; please replace it by your own IP machine.

sudo -s
apt-get install git
apt-get install mongodb-server
nano /etc/mongodb.conf          # replace 127.0.0.1 by the machine IP

mkdir /mongo
mkdir /mongo/metadata
mkdir /mongo/query
mkdir /mongo/shard01
mkdir /mongo/shard02
mkdir /mongo/shard03
mkdir /mongo/shard04

export LC_ALL=C
service mongodb stop
nohup mongod --configsvr --dbpath /mongo/metadata --port 27019 >> /mongo/metadata.log &
tail -30 /mongo/metadata.log

nohup mongos --configdb 192.168.1.65:27019 >> /mongo/query.log &
tail -30 /mongo/query.log

nohup mongod --dbpath /mongo/shard01 --port 21117 >> /mongo/shard01.log &
nohup mongod --dbpath /mongo/shard02 --port 21217 >> /mongo/shard02.log &
nohup mongod --dbpath /mongo/shard03 --port 21317 >> /mongo/shard03.log &
nohup mongod --dbpath /mongo/shard04 --port 21417 >> /mongo/shard04.log &
tail -30 /mongo/shard01.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment