Created
August 25, 2011 01:18
-
-
Save bmarini/1169735 to your computer and use it in GitHub Desktop.
Local Replica Set
This file contains 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
mkdir ~/tmp_mongo_data1 | |
mkdir ~/tmp_mongo_data2 | |
mkdir ~/tmp_mongo_data3 | |
# In separate terminals | |
mongod --dbpath ~/tmp_mongo_data1 --port 5000 --replSet ben | |
mongod --dbpath ~/tmp_mongo_data2 --port 5001 --replSet ben | |
mongod --dbpath ~/tmp_mongo_data3 --port 5002 --replSet ben | |
# Then setup replication in a 4th terminal | |
echo 'rs.initiate({ _id: "ben", members: [ { _id: 0, host: "localhost:5000" } ] })' | mongo localhost:5000 | |
echo 'rs.add("localhost:5001")' | mongo localhost:5000 | |
echo 'rs.add("localhost:5002")' | mongo localhost:5000 | |
# Now you can connect to your replica set | |
mongo localhost:5000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment