问题描述
我最近将我的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.
您的帮助将得到预先的感谢!
Your help is appreciated in advance!
我一直在我的服务器目录中搜寻,试图在其中成功运行meteor mongo
,但是尽管事实上我已经在curl https://install.meteor.com | /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:
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:
因此,根据其中一个答案的建议,我编辑了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:[email protected]: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库,但是我很想找到一种方法来直接远程访问我的数据库,并且仍然继续使用流星.
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并为您进行设置.来自流星"文档:
It is impossible to remotely access the database, if Meteor Up installed and set it up for you. From the Meteor Up docs:
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小滴具有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
这篇关于流星Up部署,不能使用流星mongo --url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!