Meteor cluster recipe

Today let’s see a recipe to create a Meteor cluster.

A few days ago I was in charge of creating a poc, a Meteor cluster. I started reading the meteorhacks:cluster package documentation again.

The first thing that I noticed is that with this package I would not to deal with Load Balancers because it turns Meteor apps into Load Balancers, in other words, it just configures your mup.json and your MongoDB.


What I used?

Two $5 Digital Ocean droplets.

A MongoDB replica set with two instances.

Mup for configuration and deployment.


Digital Ocean

First at all, let’s start creating our droplets on Digital Ocean.

Image 2015-06-19 at 7.28.27 AM.png

Image 2015-06-19 at 12.50.45 PM.png

After that just click on the name of your instances to see what are your ip addresses, both, the public and the private. You’ll find this information in the settings section.

Image 2015-06-19 at 1.52.39 PM.png

You’ll use it to configure your mup.json



Ok, now you have your droplets and know your ips, you can configure your mup.json. As usual, there’s no secret to configure and use mup, you can see the example that I used here ( blog ) and use it as a reference.

Maybe you noticed that I used mup to configure and install even MongoDB

"setupMongo": true,

If you want to delegate those( setup ) to mup, all you have to do is:

mup setup




Now connect on all your instances to configure MongoDb replica set. The first commands you’ve to execute on all all servers

The first thing is to export LC_ALL variable, it’s better if you write to the file .bashrc

export LC_ALL=C


Now stop your MongoDb instances

sudo service mongod stop


Create the database directories ( it’s possible to change that, just use the –dbpath parameter )

sudo mkdir -p /data/db
sudo mongod --replSet "rs0";


Now, just on the “PRIMARY” server, set the members of your replica set.

config = {_id: 'rs0', members: [{_id: 0, host: 'SERVER-IP:27017'}, {_id: 1, host: 'SERVER-IP:27017'}]};


Check the status of your configuration



“Maybe you want to change what server will be the Primary, if it’s your case just change server’s priorities.”

config.members[0].priority = 1
config.members[1].priority = 0.5


Now on the “PRIMARY” server create the oplog user. First switch to admin database

use admin
db.createUser({user: "oplogger", pwd: "PASSWORD", roles: [{role: "read", db: "local"}]});


Check to see with your own eyes if it’s there

show users
"_id" : "admin.oplogger",
"user" : "oplogger",
"db" : "admin",
"roles" : [
"role" : "read",
"db" : "local"




Now that you have everything configured, it’s just to deploy

mup deploy


If something goes wrong you can see what happened reading the logs

mup logs -n 300


In my example, my first try fails, why?

Error: $ROOT_URL, if specified, must be an URL


Backup and Restore

If for some reason you already have a database and want to restore it on your new replica set, starting by the dump 🙂

mongodump --db DBNAME --out ./DBNAME
tar -cvf DBNAME.tar DBNAME


Yes, MongoDB dumps are directories.

copy to the new server…

mongorestore DBNAME



That’s it, another job that became easier because of Meteorhacks folks.


Allan de Queiroz

Allan de Queiroz
London based software engineer

XServer forward from Linux text mode for Headless purposes.

Hello, this post is about XServer forward from Linux text mode, **not ssh forward, anything related to VNC** or things like that.Recently...… Continue reading