Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save filipenevola/151f7156fde27436a83fba14c2ff12c7 to your computer and use it in GitHub Desktop.
Save filipenevola/151f7156fde27436a83fba14c2ff12c7 to your computer and use it in GitHub Desktop.
Setting up a local MongoDB 4.0.x replica set with oplog for use with Meteor

From an appropriate location:

mkdir -p /srv/mongodb/rs0-0 /srv/mongodb/rs0-1 /srv/mongodb/rs0-2
mongod --port 27018 --dbpath /srv/mongodb/rs0-0 --replSet rs0 --smallfiles --oplogSize 128 &
mongod --port 27018 --dbpath /srv/mongodb/rs0-1 --replSet rs0 --smallfiles --oplogSize 128 &
mongod --port 27019 --dbpath /srv/mongodb/rs0-2 --replSet rs0 --smallfiles --oplogSize 128 &
mongo --port 27017

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

In the Mongo shell:

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

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

Then to run your Meteor app with oplog tailing:

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