Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Created July 12, 2013 16:10
Show Gist options
  • Save wolf0403/5985622 to your computer and use it in GitHub Desktop.
Save wolf0403/5985622 to your computer and use it in GitHub Desktop.
MongoDB replica setup
# When connecting using pymongo, specify "replicaSet"
# This allows default port running secondary nodes.
pymongo.MongoClient(replicaSet='rs0', slaveOk=True)
port = 27017
bind_ip = 127.0.0.1
dbpath = /path/to/mongo-db/rs.0
logpath = /path/to/mongo-db/rs0.log
replSet = rs0
port = 27017
bind_ip = 127.0.0.1
dbpath = /path/to/mongo-db/rs.1
logpath = /path/to/mongo-db/rs1.log
replSet = rs0
[program:mongo-rs0]
command=/path/to/mongo/bin/mongod -f /path/to/mongo/conf.rs0
directory=/path/to/mongo
autorestart=true
autostart=true
[program:mongo-rs1]
command=/path/to/mongo/bin/mongod -f /path/to/mongo/conf.rs1
directory=/path/to/mongo
autorestart=true
autostart=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment