Meteor Up部署,不能使用meteor mongo --url

bla*_*neh 9 ssh mongodb meteor digital-ocean meteor-up

我最近将我的Meteor应用程序部署到运行Ubuntu 14.04 x32的Digital Ocean液滴中.我在这个文件中使用了Meteor Upmup.json:

{
  // Server authentication info
  "servers": [
    {
      "host": "mycorrecthostname",
      "username": "root",
      "password": "mycorrectpassword"
    }
  ],

  // Install MongoDB in the server, does not destroy local MongoDB on future setup
  "setupMongo": true,

  // WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
  "setupNode": true,

  // WARNING: If nodeVersion omitted will setup 0.10.25 by default. Do not use v, only version number.
  "nodeVersion": "0.10.28",

  // Install PhantomJS in the server
  "setupPhantom": true,

  // Application name (No spaces)
  "appName": "meteor",

  // Location of app (local directory)
  "app": "/my/correct/path/to/app",

  // Configure environment
  "env": {
    "ROOT_URL": "http://mycorrecturl.com"
  },

  // Meteor Up checks if the app comes online just after the deployment
  // before mup checks that, it will wait for no. of seconds configured below
  "deployCheckWaitTime": 15
}
Run Code Online (Sandbox Code Playgroud)

一切都很好.我测试了网站,一切都按照应有的方式运作.我还ssh用服务器设置了我的密钥,并且可以ssh在没有密码的情况下使用它.

现在,我需要远程访问我的服务器数据库.我在python shelf文件中有一些本地数据,我需要为我的数据库播种.我理解如何连接到远程数据库pymongo,但我正在尝试获取连接URI,meteor mongo --url http://mycorrecturl.com/它只是返回此错误:

Couldn't open a mongo connection: Site does not exist
Run Code Online (Sandbox Code Playgroud)

什么??这里出了什么问题?我希望它要求身份验证,但只是不存在?官方的困惑.

提前感谢您的帮助!

更新

我一直在我的服务器目录中寻找,试图在meteor mongo那里成功运行,但尽管我已经安装了meteor curl https://install.meteor.com | /bin/sh,但它总是说我不在流星项目目录中.甚至隐藏的.meteor目录显然也不是项目目录.

更新

我更仔细地看了Meteor Up文档,它说:

您无法从服务器外部访问MongoDB.要访问MongoDB shell,您需要先通过SSH登录服务器,然后运行以下命令.

mongo appName
Run Code Online (Sandbox Code Playgroud)

我尝试了它并且它有效,但那还不够好.我需要能够远程访问数据库.Meteor Up部署根本不可能吗?

下面的答案之一似乎是建议通过MONGO_URL在我的env对象中设置,我将基本上手动告诉数据库要响应的URL.那是准确的吗?

更新

Meteor Up文档说如下:

<appName>是数据库的名称

所以,根据其中一个答案的建议,我编辑了我的内容mup.json:

// Configure environment
"env": {
  "ROOT_URL": "http://localhost/",
  "MONGO_URL": "mongodb://root:mypassword@127.0.0.1:27017/meteor"
  // My appName is "meteor", so that is the name of the database as well.
}
Run Code Online (Sandbox Code Playgroud)

当我mup deploy使用这些变量执行时,部署失败.这是错误的第一部分(如果你想看到剩下的让我知道):

/usr/lib/node_modules/wait-for-mongo/bin/wait-for-mongo:14
    throw err;
Run Code Online (Sandbox Code Playgroud)

当我使用时mup reconfigure,它不会失败,但是网站根本无法找到它的网址.在我看来,它MONGO_URL不是一个控制机制,而只是一个指向外部数据库的指针,如mongohq.

我想我别无选择,只能求助于mongo appName会议和ssh python库,但我很想找到一种方法来远程直接访问我的数据库并继续使用Meteor Up.

bla*_*neh 7

如果安装Meteor Up并为您设置,无法远程访问数据库.来自Meteor Up的文档:

您无法从服务器外部访问MongoDB.要访问MongoDB shell,您需要先通过SSH登录服务器,然后运行以下命令.

mongo appName
Run Code Online (Sandbox Code Playgroud)

但是mongo appName,如果这些程序在服务器上运行,可以通过除该接口之外的其他方式访问它.

数字海洋Ubuntu水滴配备了Python 2.7,因此使用pymongo是可能的.此命令将连接到您:

from pymongo import MongoClient
client = MongoClient()
Run Code Online (Sandbox Code Playgroud)

这将自动连接到 mongodb://localhost:27017/

pymongo不是默认包,所以安装pip,然后使用pip安装pymongo.

apt-get install python-pip python-dev build-essential
pip install pymongo
Run Code Online (Sandbox Code Playgroud)