Created
May 31, 2018 07:52
-
-
Save mansurali901/3e9f08b85170cd1819c950a0e6ae869f to your computer and use it in GitHub Desktop.
Setup Mongo Replica Sets on Ubuntu 16.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is written to setup mongo replicasets | |
# There are three replicas for Mongo replication | |
# Author : Mansur Ul Hasan | |
# Email : [email protected] | |
mkdir /var/lib/mongod{1..3} | |
mongod --replSet burraq --logpath "/var/log/mongodb/mongod1.log" --dbpath /var/lib/mongod1 --port 27017 & | |
mongod --replSet burraq --logpath "/var/log/mongodb/mongod2.log" --dbpath /var/lib/mongod2 --port 28017 & | |
mongod --replSet burraq --logpath "/var/log/mongodb/mongod3.log" --dbpath /var/lib/mongod3 --port 29017 & | |
mongo <<EOF | |
config = { _id: "burraq", members:[ | |
{ _id : 0, host : "localhost:27017"}, | |
{ _id : 1, host : "localhost:28017"}, | |
{ _id : 2, host : "localhost:29017"} ] | |
}; | |
EOF | |
mongo <<EOF | |
rs.initiate(config); | |
EOF | |
mongo <<EOF | |
rs.status(); | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment