Meteor 1.4.1.1 上副本集的正确 MONGO_URL 设置是什么

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

今天早上,我将更新后的 Meteor 项目部署到 Heroku 上。

我正在从 1.1.0.3 升级到 1.4.1.1

使用 Meteor Buildpack Horse 一切都安装正确,但应用程序因错误而出错;

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

我的 MONGO_URLmongodb://u:p@url1:port,url2:port/db 所以我把它改成了;

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

如果我对 replicaSet 参数有误,我会得到这个错误;

MongoError: no primary found in replicaset

这似乎是明智的,因为副本集不存在,但是当我输入正确的值时,我再次收到原始错误,说种子列表不包含代理。

我的副本集名称中有一个破折号,我不知道这是否相关。

我试过的

我试过使用 URL 在 Mongo 客户端中抛出这个错误,它允许我连接到实例,所以我知道所有的细节都是正确的。

我也试过转义副本集,所以 ?replicaSet=set\-name 这给了我 MongoError: no primary found in replicaset 错误。

我的 MongoDB 供应商有一个开放的工单,但我怀疑这是一个 Meteor/me 问题!

Meteor v1.4 使用了新版本的 MongoDB 驱动。

虽然 MONGO_URL 环境变量的格式正确,但错误是由 MONGO_OPLOG_URL 引起的,应修改为包含 replicaSet 参数。

有关详细信息和以下注释(关于 Compose.io),请参阅 this GitHub issue

来自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.

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.