Toby
Toby

Reputation: 8792

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

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!

Upvotes: 6

Views: 7301

Answers (1)

MasterAM
MasterAM

Reputation: 16478

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.

Upvotes: 6

Related Questions