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

今天早上我去部署我更新的 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

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

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

我尝试过的

我尝试使用在 Mongo 客户端中引发此错误的 URL,它允许我很好地连接到实例,所以我知道所有详细信息都是正确的。

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

我的 MongoDB 提供商有一张未结的票,但我怀疑这是 Meteor/me 的问题!

最佳答案

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

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

见 this GitHub issue有关更多详细信息和以下说明(关于 Compose.io)。

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

https://stackoverflow.com/questions/39315149/

相关文章:

node.js - 如何使用 mongo/mongoose 连接远程数据库

mongodb - 使用 mongoose 正则表达式与文本在 mongodb 中搜索

json - 如何使用 Pentaho 从 json 中的三个表到 mongodb 执行复杂文档

node.js - Node/Express - 保护客户端/服务器之间通信的好方法

node.js - Nodejs 我需要使用 Passport

node.js - 如何使用 MongoDB 按名字和姓氏搜索用户?

node.js - Mongoose 在未指定的时间段后停止响应

node.js - 我可以在 MongoDB 的聚合查询中申请 forEach 吗?

ruby-on-rails - 在 Rails 控制台中列出所有 Mongoid 模型

node.js - 我的 Electron 应用程序启动时如何启动 mongodb 服务