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

前端 未结 7 1264
-上瘾入骨i
-上瘾入骨i 2020-12-09 06:21

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:



        
相关标签:
7条回答
  • 2020-12-09 06:27

    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.

    0 讨论(0)
  • 2020-12-09 06:28

    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.

    0 讨论(0)
  • 2020-12-09 06:42

    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
    
    0 讨论(0)
  • 2020-12-09 06:46

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

    0 讨论(0)
  • 2020-12-09 06:52

    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.

    0 讨论(0)
  • 2020-12-09 06:53

    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.

    0 讨论(0)
提交回复
热议问题