Skip to content

Instantly share code, notes, and snippets.

@rynr
Created August 30, 2013 13:50
Show Gist options
  • Save rynr/6390047 to your computer and use it in GitHub Desktop.
Save rynr/6390047 to your computer and use it in GitHub Desktop.
Create a mongo-rs for testing
i=0
name=rs01
while [ $i -lt 3 ]
do let i=i+1
echo "Starting mongodb $i at Port 2222$i"
mkdir db$i
mongod --port 2222$i --fork --dbpath db$i --syslog --replSet $name
if [ $i -eq 1 ]
then echo "rs.initiate({_id: \"$name\", members: [{_id: 0, host: \"localhost:2222$i\"}]})" | mongo localhost:22221
else echo "rs.add(\"localhost:2222$i\")" | mongo localhost:22221
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment