Skip to content

Instantly share code, notes, and snippets.

@chfritz
Created February 27, 2021 00:11
Show Gist options
  • Save chfritz/6fc8dc807cf12816f6cf5c6be2f5f837 to your computer and use it in GitHub Desktop.
Save chfritz/6fc8dc807cf12816f6cf5c6be2f5f837 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script to enable oplog tailing in a production meteor deployment using mongodb 4.0 or later
echo "# Enabling replication, required for oplog tailing" >> /etc/mongod.conf
echo "replication:" >> /etc/mongod.conf
echo " oplogSizeMB: 100" >> /etc/mongod.conf
echo " replSetName: rs0" >> /etc/mongod.conf
systemctl restart mongod
sleep 2
echo 'rs.initiate({ "_id" : "rs0", "version" : 1, "members" : [{ "_id" : 0, "host" : "127.0.0.1:27017" }]})' | mongo
sleep 1
mongo admin -eval 'db.createUser({user: "oplogger", pwd: "PasswordForOplogger", roles: ["read"]})'
echo
echo "All set! Now use"
echo " MONGO_OPLOG_URL=mongodb://oplogger:PasswordForOplogger@localhost:27017/local?replicaSet=rs0\&authSource=admin"
echo "in your meteor app"
@chfritz
Copy link
Author

chfritz commented Feb 28, 2021

Download and run in one line:

curl https://gist.githubusercontent.com/chfritz/6fc8dc807cf12816f6cf5c6be2f5f837/raw/c81370f5c77f3dcc50c04e9685f23550e755c084/enable_oplog_meteor.sh | sudo sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment