Meteor Up 部署,不能使用meteor mongo --url [英] Meteor Up deployment, can't use meteor mongo --url
问题描述
我最近将我的 Meteor 应用程序部署到运行 Ubuntu 14.04 x32 的 Digital Ocean Droplet.我在这个 mup.json
文件中使用了 Meteor Up:
I've recently deployed my Meteor app to a Digital Ocean droplet running Ubuntu 14.04 x32. I used Meteor Up with this mup.json
file:
{
// 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
}
一切都很好.我已经测试了该网站,一切正常.我还在服务器上设置了我的 ssh
密钥,并且可以在没有密码的情况下 ssh
到它.
Everything works great. I have tested the website, and everything works just the way it should. I've also set up my ssh
keys with the server, and can ssh
to it without a password.
现在,我需要远程访问我的服务器数据库.我在 python shelf
文件中有一些本地数据,我需要用它来为我的数据库做种.我了解如何使用 pymongo
连接到远程数据库,但我正在尝试使用 meteor mongo --url http://mycorrecturl.com/
获取连接 URI它只是返回这个错误:
Now though, I need to access my server database remotely. I have some local data in a python shelf
file that I need to seed my database with. I understand how to connect to a remote database with pymongo
, but I'm trying to get a connection URI with meteor mongo --url http://mycorrecturl.com/
and it just returns this error:
Couldn't open a mongo connection: Site does not exist
什么??这里出了什么问题?我希望它要求身份验证,但只是不存在?官方混淆.
What?? What is going wrong here? I would expect it to ask for authentication, but just not existing? Officially confused.
提前感谢您的帮助!
我一直在我的服务器目录中四处寻找,试图在那里成功运行 meteor mongo
,但尽管我已经使用 curl https://install 安装了meteor.流星网|/bin/sh
,它只是总是说我不在流星项目目录中.甚至隐藏的 .meteor
目录显然也不是项目目录.
I've been hunting around in my server directories, trying to successfully run meteor mongo
there, but despite the fact that I've installed meteor with curl https://install.meteor.com | /bin/sh
, it simply always says that I'm not in a meteor project directory. Even the hidden .meteor
directory apparently wasn't a project directory.
我更仔细地查看了 Meteor Up 文档,它说:
I've looked more closely at the Meteor Up docs, and it says this:
您无法从服务器外部访问 MongoDB.访问您需要首先通过 SSH 登录到您的服务器的 MongoDB shell然后运行以下命令.
You can't access the MongoDB from the outside of the server. To access the MongoDB shell you need to log into your server by SSH first and then run the following command.
mongo appName
我试过了,它有效,但这还不够好.我需要能够远程访问数据库.Meteor Up 部署根本不可能吗?
I tried that out and it works, but that's not good enough. I need to be able to access the database remotely. Is it simply impossible with a Meteor Up deployment?
下面的一个答案似乎暗示通过在我的 env
对象中设置 MONGO_URL
,我基本上会手动告诉数据库要响应的 url.准确吗?
One of the answers below seems to be suggesting that by setting the MONGO_URL
in my env
object, that I will basically be manually telling the database what url to respond to. Is that accurate?
Meteor Up 文档如下:
The Meteor Up docs say the following:
<appName> is the name of the database
因此,根据其中一个答案的建议,我编辑了我的 mup.json
以包含以下内容:
So, on the advice of one of the answers, I edited my mup.json
to include this:
// 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.
}
当我使用这些变量执行 mup deploy
时,部署失败.这是错误的第一部分(如果您想查看其余部分,请告诉我):
When I execute mup deploy
with those variables, the deployment fails. Here's the first part of the error (if you'd like to see the rest let me know):
/usr/lib/node_modules/wait-for-mongo/bin/wait-for-mongo:14
throw err;
当我使用 mup reconfigure
时,它不会失败,但是在它的 url 上根本找不到该网站.在我看来,MONGO_URL
不是一种控制机制,而只是一个指向外部数据库(如 mongohq)的指针.
When I use mup reconfigure
, it doesn't fail, but then the website simply cannot be found at it's url. It seems to me that the MONGO_URL
isn't a control mechanism, but merely a pointer to an outside database such as mongohq.
我想我别无选择,只能求助于 mongo appName
约定和 ssh python 库,但是 我很想找到一种方法来直接访问我的远程数据库并继续使用 Meteor Up.
I'm thinking I'll have no choice but to resort to the mongo appName
convention and an ssh python library, but I'd love to find a way to directly access my database remotely and still keep using Meteor Up.
推荐答案
无法远程访问数据库,如果 Meteor Up 已安装并为您设置.来自 Meteor Up 文档:
It is impossible to remotely access the database, if Meteor Up installed and set it up for you. From the Meteor Up docs:
您无法从服务器外部访问 MongoDB.访问您需要首先通过 SSH 登录到您的服务器的 MongoDB shell然后运行以下命令.
You can't access the MongoDB from the outside of the server. To access the MongoDB shell you need to log into your server by SSH first and then run the following command.
mongo appName
然而,它可以通过 mongo appName
接口以外的其他方式访问,如果那些程序在服务器上运行.
It can however be accessed in other ways than that mongo appName
interface, if those programs are running on the server.
Digital Ocean Ubuntu droplets 配备了 Python 2.7,所以使用 pymongo是可能的.此命令将连接您:
Digital Ocean Ubuntu droplets come equipped with Python 2.7, so using pymongo is possible. This command will connect you:
from pymongo import MongoClient
client = MongoClient()
这将自动连接到 mongodb://localhost:27017/
pymongo
不是默认包,所以安装 pip
,然后使用 pip
安装 pymongo
.
pymongo
isn't a default package, so install pip
, and then use pip
to install pymongo
.
apt-get install python-pip python-dev build-essential
pip install pymongo
这篇关于Meteor Up 部署,不能使用meteor mongo --url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!