What is the correct MONGO_URL setting for replica sets on Meteor 1.4.1.1
Asked Answered
A

1

6

This morning I went to deploy my updated Meteor project onto Heroku.

I was upgrading from 1.1.0.3 to 1.4.1.1.

Using the Meteor Buildpack Horse everything installed correctly, but the application was erroring out with the error;

MongoError: seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name

My MONGO_URL was mongodb://u:p@url1:port,url2:port/db so I changed it to;

mongodb://u:p@url1:port,url2:port/db?replicaSet=set-name

If I made a mistake with the replicaSet param I would get this error;

MongoError: no primary found in replicaset

Which seems sensible, since the replicaset didn't exist, but when I put the correct value in I get that original error again saying the seed list contains no proxies.

My replica set has a dash in the name, I don't know if that is relevant.

What I've tried

I've tried using the URL that throws this error in a Mongo client and it allows me to connect to the instance fine, so I know all the details are correct.

I've also tried escaping the replicaSet, so ?replicaSet=set\-name this gave me the MongoError: no primary found in replicaset error.

I have an open ticket with my MongoDB provider, but I suspect this is a Meteor/me issue!

Alga answered 4/9, 2016 at 8:51 Comment(6)
I don't think you're doing anything wrong which is really strange. I am currently using the following structure in an app I am working on: mongodb://username:[email protected]:PORT1,url2.com:PORT2/database?replicaSet=set-000000a0aaaa0000a00000a0Aspia
Also keep in mind your meteor settings file follows strict JSON requirements (no trailing commas for example).Aspia
@AndrewHill can you elaborate on the strict JSON requirements? Where could I be running foul of that? (my settings.json is empty)Alga
another suggestion, maybe there's issue with mongo package, in our production we use [email protected]Pannonia
Where is your DB hosted? Did you update the MONGO_OPLOG_URL variable as well? Have you seen this issue?Cuttlebone
@MasterAMthat OPLOG was exactly the issue! Thank you so much! My google-fu failed me there. Can you write up as an answer and I will send the bounty!Alga
C
6

Meteor v1.4 uses a new version of the MongoDB driver.

While the MONGO_URL environment variable was in the correct form, the error was caused by MONGO_OPLOG_URL, which should be modified to include a replicaSet argument.

See this GitHub issue for more details and the following notes (regarding Compose.io).

From the oplog driver documentation:

Oplog tailing is automatically enabled in development mode with meteor run, and can be enabled in production with the MONGO_OPLOG_URL environment variable.

(...)

To use oplog tailing in your production Meteor app, your MongoDB servers must be configured as a replica set; a single-mongod database has no oplog. Your cluster may not use Mongo sharding.

And the migration guide:

As of 1.4, you must ensure your MONGO_OPLOG_URL contains a replicaSet argument (see the changelog and the oplog documentation).

NOTE: Some MongoDB hosting providers may have a deployment setup that doesn't require you to use a replicaSet argument. For example, Compose.io has two types of deployments, MongoDB Classic and MongoDB+. The new MongoDB+ offering is a sharded setup and not a true replica set (despite the shard being implemented as a replica set) so it does not require the replicaSet parameter and Meteor will throw an error if you add it to your connection strings.

Cuttlebone answered 10/9, 2016 at 7:16 Comment(2)
What if you don't want to use Oplog?Favianus
@Yeats, Simply don't set the MONGO_OPLOG_URL environment variable. But if you do, make sure it follows the requirements.Cuttlebone

© 2022 - 2024 — McMap. All rights reserved.