Skip to content

Instantly share code, notes, and snippets.

@richsilv
Created February 3, 2016 16:47
Show Gist options
  • Save richsilv/4a502d95963c1c80f58a to your computer and use it in GitHub Desktop.
Save richsilv/4a502d95963c1c80f58a to your computer and use it in GitHub Desktop.
Setting up a local MongoDB replica set with oplog for use with Meteor

From an appropriate location:

mkdir replica-set
mkdir -p replica-set/rs0-0 replica-set/rs0-1
mongod --port 27018 --dbpath replica-set/rs0-0 --replSet rs0 --smallfiles --oplogSize 128 &
mongod --port 27019 --dbpath replica-set/rs0-1 --replSet rs0 --smallfiles --oplogSize 128 &
mongo localhost:27018

=====================

In the Mongo shell:

config = {_id: 'rs0', members: [{_id: 0, host: 'localhost:27018'}, {_id: 1, host: 'localhost:27019'}]}
rs.initiate(config)
use admin
db.createUser({user:'oplogger', pwd:'PASSWORD',roles:[{role: 'read', db: 'local'}]})

=====================

Then to run your Meteor app with oplog tailing:

MONGO_URL='mongodb://localhost:27018/APP_NAME' MONGO_OPLOG_URL='mongodb://oplogger:PASSWORD@localhost:27018,localhost:27019/local?authSource=admin' meteor --settings settings.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment