mongodbsshmeteordigital-oceanmeteor-up

Meteor Up deployment, can't use meteor mongo --url


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
}

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.

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!

Update

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.

Update

I've looked more closely at the Meteor Up docs, and it says this:

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

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?

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?

Update

The Meteor Up docs say the following:

<appName> is the name of the database

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.
}

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;

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.

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.


Solution

  • It is impossible to remotely access the database, if Meteor Up installed and set it up for you. From the Meteor Up docs:

    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
    

    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 come equipped with Python 2.7, so using pymongo is possible. This command will connect you:

    from pymongo import MongoClient
    client = MongoClient()
    

    That will automatically connect at mongodb://localhost:27017/

    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