如何设置Mongo URL?

时间:2016-11-07 13:24:13

标签: mongodb meteor

我正在尝试部署我的项目,但是当我在项目日志中检查日志时,我收到以下错误:

2016-11-07 20:23:45+08:00Error: MONGO_URL must be set in environment
5ar3
2016-11-07 20:23:45+08:00 at Object.<anonymous> (packages/mongo/remote_collection_driver.js:36:11)
5ar3
2016-11-07 20:23:45+08:00 at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
5ar3
2016-11-07 20:23:45+08:00 at new Mongo.Collection (packages/mongo/collection.js:103:40)
5ar3
2016-11-07 20:23:45+08:00 at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
5ar3
2016-11-07 20:23:45+08:00 at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)
5ar3
2016-11-07 20:23:45+08:00 at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
5ar3
2016-11-07 20:23:45+08:00 at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
5ar3
2016-11-07 20:23:45+08:00 at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
5ar3
2016-11-07 20:23:45+08:00 at /app/bundle/programs/server/packages/accounts-base.js:1838:15
5ar3
2016-11-07 20:23:45+08:00 at /app/bundle/programs/server/packages/accounts-base.js:1849:3
5ar3
2016-11-07 20:23:45+08:00Application exited with code: 1 signal: null
5ar3
2016-11-07 20:23:45+08:00Application process closed with code: 1 signal: null
5ar3
2016-11-07 20:24:08+08:00The container has crashed. A new container will be started to replace it.
k13z
2016-11-07 20:27:43+08:00Application process starting, version: 2 on apprunner (embedded)
k13z
2016-11-07 20:27:52+08:00/app/bundle/programs/server/node_modules/fibers/future.js:280
k13z
2016-11-07 20:27:52+08:00   throw(ex);
k13z
2016-11-07 20:27:52+08:00   ^
k13z
2016-11-07 20:27:52+08:00
k13z
2016-11-07 20:27:52+08:00Error: MONGO_URL must be set in environment
k13z
2016-11-07 20:27:52+08:00 at Object.<anonymous> (packages/mongo/remote_collection_driver.js:36:11)
k13z
2016-11-07 20:27:52+08:00 at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
k13z
2016-11-07 20:27:52+08:00 at new Mongo.Collection (packages/mongo/collection.js:103:40)
k13z
2016-11-07 20:27:52+08:00 at AccountsServer.AccountsCommon (packages/accounts-base/accounts_common.js:23:18)
k13z
2016-11-07 20:27:52+08:00 at new AccountsServer (packages/accounts-base/accounts_server.js:18:5)
k13z
2016-11-07 20:27:52+08:00 at meteorInstall.node_modules.meteor.accounts-base.server_main.js (packages/accounts-base/server_main.js:9:12)
k13z
2016-11-07 20:27:52+08:00 at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
k13z
2016-11-07 20:27:52+08:00 at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
k13z
2016-11-07 20:27:52+08:00 at /app/bundle/programs/server/packages/accounts-base.js:1838:15
k13z
2016-11-07 20:27:52+08:00 at /app/bundle/programs/server/packages/accounts-base.js:1849:3

从错误中看,它似乎与我在settings.json文件中设置Mongo网址的方式有关

这是我在settings.json文件中设置的方式:

{
  "AWSAccessKeyId": "ID
  "AWSSecretAccessKey": "SECRETID",
  "public": {
    "analyticsSettings": {
      "Google Analytics" : {"trackingId": "sdsd-dlsfs-1"}
    },
    "galaxy.meteor.com": { 
     "env": { 
       "MONGO_URL": "mongodb://<dbuser>:<dbpassword>@dfd43435.mlab.com:2423/dbname" 
     } 
   }
  }
}

我在这里做错了什么?

4 个答案:

答案 0 :(得分:0)

您需要将galaxy.meteor.com放在public字段之外。

答案 1 :(得分:0)

您是否在

中设置了Mlab信息
allmap >> map1,map3,map2

正确?

必须设置

dbuser / dbpassword / dbname才能将数据库与已部署的应用程序连接。

答案 2 :(得分:0)

我设法通过删除???? ???????? ?????? ???????? ???? ?????? ?????????????? <somemark>?????? ????</somemark> ?????? ????文件并创建新文件来解决它。我手动输入了settings.json的内容。

似乎文件中有隐藏的字符。

答案 3 :(得分:0)

您使用的是Windows命令提示符吗?首先输入以下命令

meteor mongo --url

上面的命令会显示你的 mongo url 。如果你想在你的本地应用程序中运行任何其他数据库,请转到根文件夹并输入以下命令

set MONGO_URL=mongodb://[username]:[password]@[host]:[port]/[databasename]

例如 - set MONGO_URL=mongodb://root:abcde@ds049476.mlab.com:48474/mydb

上面的命令正在使用windows