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

你离开我真会死。 提交于 2019-11-28 07:46:05

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

It's because you did not set the MONGO_URL in the "env" object.

// Configure environment
"env": {
    "PORT": 58090, # Your application port
    "ROOT_URL": "http://localhost/",
    "MONGO_URL": "mongodb://username:password@127.0.0.1:27017/myDatabase",
    "METEOR_ENV": "production"  # If you need to separate your local environment from production
},

Then, just run mup deploy.

It took me a while to figure this out. It is not possible to access the mongodb server from outside your hosting server. Therefore, you have to ssh into your server first and work from there. To connect to your db with pymongo, use the following:

client = MongoClient('mongodb://localhost/APPNAME')
posts = client.APPNAME.posts

APPNAME should be specified in your mup.json file and replace posts with whatever collection you must update.

I think I found a solution for accessing the DB with mupx on a digitalocean ubuntu 14.04 server.

After deployment of your app with mupx, do the following:

Login with ssh into your server, then install mongo: apt-get install mongodb

Then run the mongo command on your server. Try checking if your DB exists by running show dbs. If it is, then use yourdbname. It should hold all the data from your running app!

Let me know if it works. Good luck.

I had this some problem but was able to use 3T MongoChef to do it. There is an option in MongoChef to connect to a DB via SSH and it worked like a charm. Hope this helps others out.

Here is the relevant screen in MongoChef from where you can do this.

You can change the mongod.conf, to allow access from outside (a bit dangerous of course ;)

nano /etc/mongod.conf

# Listen to local interface only. Comment out to listen on all     interfaces.
# bind_ip = 127.0.0.1

then restart the server

service mongod stop
service mongod start

and you can access it from outside (using ssh-forwarding in robo-mongo)

All I did was add the IP of my Digital ocean droplet server, instead of localhost, and it worked:

env: {
      ROOT_URL: 'http://yourdomain.com',
      MONGO_URL: 'mongodb://104.236.24.66:27017/meteor',
      PORT: 3002,
    },

Using this mongo instance in docker for 2 meteor apps currently.

EDIT: This depends on how your firewall is setup. Check with "ufw status". Also depends on how your mongo is deployed (which ports forwarded to where; ex) 0.0.0.0:27017->27017 ).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!