How to add oplog tailing to meteor up (mup) on Ubuntu

Vianney Lecroart
Meteor Secret
Published in
3 min readFeb 26, 2015

By default, the amazing Meteor Up tool (also called mup by lazy people like me) setup everything you need to deploy easily a Meteor app on your own server.

But for the moment, it doesn’t setup oplog tailing to optimise mongo data updates.

I found lot of articles on how to setup oplog tailing but they are often out of date, incomplete or not really easy to follow. So since I just added oplog on my server that use meteor up, I thought it could be useful to write a step-by-step article so you’ll not have to dig on all those articles.

I supposed that you already deployed your application with mup (if not, start here) and it runs correctly on your Ubuntu server.

Here is what you have to do to add oplog tailing:

  • connect to your Ubuntu server
  • edit mongod config file /etc/mongod.conf (note it’s not the same as /etc/mongodb.conf)
  • uncomment the line port = 27017 (if you don’t see this commented line, you edit the wrong file)
  • uncomment the line starting with replSet and set the variable to meteor. It should be: replSet=meteor
  • save the file
  • restart mongod: service mongod restart
  • connect to mongod: mongo
  • copy paste the following code
var config = {_id: "meteor", members: [{_id: 0, host: "127.0.0.1:27017"}]}
rs.initiate(config)

It should output something like:

{
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}

Note: Be sure your mongod is only accessible from localhost (it’s the case by default on meteor up). If mongod is accessible outside and you don’t setup role-based access control, everybody will be able to access and edit your database!

  • find the name of the database used by your Meteor app (you’ll need it later) with this command: show dbs

Now, locally, on your dev computer:

  • open mup.json and add these 2 lines in the “env” object:
"MONGO_URL": "mongodb://127.0.0.1:27017/XXXXXXXXXX",
"MONGO_OPLOG_URL": "mongodb://127.0.0.1:27017/local",

Be sure to replace XXXXXXXXXX with the name of your database (found by show dbs command)

  • deploy: mup deploy

Now your server should use oplog tailing.

How to know if oplog is correctly working?

MDG made a special package called facts that give you some information about that. Everything is explained here but if you don’t want to read it, here is what you have to do:

  • Install the package: meteor add facts
  • Add the template {{> serverFacts}} where you want to display the information
  • If you removed autopublish package, add the following line on a Meteor server file so everybody can see the stats (it’s just for test anyway):
Facts.setUserIdFilter(function () { return true; });
  • mup deploy your code and you should see something like this:

The important information is observe-drivers-oplog that tells you how many observers are managed by oplog. If you don’t see this line or if it displays 0, it means oplog is not working.

observe-drivers-polling tells you how many observes are working with poll-diff system (so without oplog).

Hope it’ll help!

--

--