What should be in mongo_url and mongo_oplog_url for monglab

Trying my first deploy to meteorapp.com. I’m using mongolab for the db but on the page I keep getting:

I’m getting a ‘502 Bad Gateway: Registered endpoints failed to handle the request.’

and in the log I get:
Error: MONGO_URL must be set in environment

The docs are a bit vague (to me) about what the string should be. Can someone post where to get the mongo_url and mongo_oplog_url from on mongolab. And perhaps an example of a settings.json file setup for mongolab.

2 Likes

In mLab once you have created your database there is a page which has this:

To connect using the mongo shell:
mongo xxxxx.mlab.com:37283/xxxxx -u <dbuser> -p <dbpassword>

To connect using a driver via the standard MongoDB URI (what's this?):
mongodb://<dbuser>:<dbpassword>@xxxxx.mlab.com:37283/xxxx

You need to copy that string into your settings.json file, mine looks like this:

{
  "kadira": {
    "appId":      "xxxxxxx",
    "appSecret":  "xxxxxxxx"
 },
 "galaxy.meteor.com": {
   "env": {
     "ROOT_URL":  "https://www.xxxxx.com.au",
     "MONGO_URL": "mongodb://xxxxx:xxxxxx@xxxxx.mlab.com:37283/xxxxx",
     "MAIL_URL":  "smtp://xxxxxx@xxxxx.com.au:xxxxxxxx@smtp.mailgun.org:25"
   }
 }
}
1 Like

Sorry in case it wasn’t clear - you need to create the database, and create a user for that database - insert the right credentials where they belong in that URL.

Thanks Chris but no luck yet. Deploying to meteor.com was so easy. Not sure
why this is so much harder. Once I get the config right once I’ll be fine.

From within the project folder I deploy from the Terminal using:

DEPLOY_HOSTNAME=galaxy.meteor.com meteor deploy appname.meteorapp.com
–settings settings.json
Here’s my settings.json which is in the root of the project.

{
galaxy.meteor.com”: {
“env”: {
“ROOT_URL”: “http://appname.meteorapp.com”,
“MONGO_URL”: “mongodb://
dbusername:dbpassword@xxxxxx.mongolab.com:63461/dbname”,
“MONGO_OPLOG_URL”: “mongodb://
dbusername:dbpassword@xxxxxx.mongolab.com:63461/dbname”
}
}
}

I haven’t setup a dns yet so try and access the app at:
appname.meteorapp.com

Here’s the thing, to enable oplog, you should first have a replicaset and I think it is not available for the free tier. So if you go for the regular, entry level paid tier, and deploy a standard replica set, you’ll end up with a database dbname and an admin database. You’ll need to create a user for your dbname and a separate oplog user for your admin database and then configure the url’s like below:

{
  "galaxy.meteor.com": {
    "env": {
      "ROOT_URL": "http://appname.meteorapp.com",
      "MONGO_URL": "mongodb://dbusername:dbpassword@xxxxxx-xx,xxxxxx-xx.mongolab.com:63461/dbname?replicaSet=rs-xxxxxx",
      "MONGO_OPLOG_URL": "mongodb://oplogdbusername:oplogdbpassword@xxxxxx-xx,xxxxxx-xx.mongolab.com:63461/local?authSource=admin"
    }
  }
}

Notice the different username:password for the oplog and the authSource parameter at the end.

4 Likes

should this be possible with the 15$ tier? Tried to set it up but got authorization errors.

Yep I got this working with the $15 tier.

Make sure you get the oplog url right (notice the very last parameter) and that you do have an oplog user defined over your admin database (not the app database)

1 Like

Success!!! Thanks cstrat and serkandurusoy for clarifying this. The last hurdle was I hadn’t setup a user for the oplog access. From mlab docs:
"The oplog provides valuable information that can be used in a variety of applications. For example, Meteor-built websites rely on the oplog to get real-time updates on data changes."
Here the last bit of detail I needed:
http://docs.mlab.com/oplog/

1 Like

So there is no free MongoDB hosting with oplog tailing?

I guess not :frowning: but there are lots of providers out there of which, some may be providing that.

Can you point me to any?

Well I was just being wishfull but I sure will let you know if/when I spot one.

1 Like

@mitar @serkandurusoy just spot this question and for anybody who will be looking for free hosting of MongoDB with oplog tailing - official hosting of Mongo Atlas have a free tier with oplog

1 Like