Skip to content

Instantly share code, notes, and snippets.

@ondrej-kvasnovsky
Created April 7, 2018 18:29
Show Gist options
  • Save ondrej-kvasnovsky/fa09b98a09c5259c554649ffea0535a4 to your computer and use it in GitHub Desktop.
Save ondrej-kvasnovsky/fa09b98a09c5259c554649ffea0535a4 to your computer and use it in GitHub Desktop.
# List existing mongo process
pgrep mongo
# Kill existing process if has.
pkill mongo
# Clear old folder if has.
rm -rf rs0 && rm -rf rs1 && rm -rf rs2
# Create log folder.
mkdir -p ./var/log/mongodb
# Create replica set 0
. rs.sh 0
# Create replica set 1
. rs.sh 1
# Create replica set 2
. rs.sh 2
# List existing mongo process
pgrep mongo
# Connect to available host
mongo
# then run: rs.initiate({_id:"rs0", members: [{_id:0, host:"127.0.0.1:27017", priority:100}, {_id:1, host:"127.0.0.1:27018", priority:50}, {_id:2, host:"127.0.0.1:27019", arbiterOnly:true}]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment