Skip to content

Instantly share code, notes, and snippets.

@giobyte8
Created November 30, 2014 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giobyte8/545732b7b8a32aef4315 to your computer and use it in GitHub Desktop.
Save giobyte8/545732b7b8a32aef4315 to your computer and use it in GitHub Desktop.
How to create a replica set in mongodb (Taken from M101JS Course)
#!/usr/bin/env bash
# Create directories for data
mkdir -p /data/rs1 /data/rs2 /data/rs3
# Start 3 server processes on three diferent ports
mongod --replSet m101 --logpath "1.log" --dbpath /data/rs1 --port 27017 --oplogSize 64 --fork --smallfiles
mongod --replSet m101 --logpath "2.log" --dbpath /data/rs2 --port 27018 --oplogSize 64 --smallfiles --fork
mongod --replSet m101 --logpath "3.log" --dbpath /data/rs3 --port 27019 --oplogSize 64 --smallfiles --fork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment