【问题标题】:How do I insert data into remote MongoDB in meteorjs? How do I know if I'm connected to the remote MongoDB?如何在meteorjs中将数据插入远程MongoDB?我如何知道我是否连接到远程 MongoDB?
【发布时间】:2015-05-03 05:30:35
【问题描述】:

我是 MongoDB 和 MeteorJS 的新手。我正在尝试将我的流星应用程序连接到远程 mongodb。我在 ec2 上有一个 mongodb 设置。这是我的 mongod.conf:

dbpath=/var/lib/mongodb
port = 27000
#bind_ip = 127.0.0.1
auth=true

我尝试将笔记本电脑上的流星应用程序连接到服务器。所以我这样做了:

#in meteor app folder
#in terminal
export MONGO_URL=mongodb://<admin>:<pwd>@<ec2-address>.compute.amazonaws.com:27000/meteor

在我的流星应用文件夹中,我有三个文件; connectmongo.html、connnectmongo.js 和 connectmongo.css

我的 connectmongo.js 看起来像这样:

Test = new Mongo.Collection('test');

然后,我在终端运行了流星命令,我得到了以下错误:

skaxwng@xps13:~/meteor/conmongo$ meteor
[[[[[ ~/meteor/conmongo ]]]]]                 

=> Started proxy.                             
W20150502-10:38:10.043(-5)? (STDERR)          
W20150502-10:38:10.046(-5)? (STDERR)   /home/skaxwng/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:278
W20150502-10:38:10.046(-5)? (STDERR)                        throw(ex);
W20150502-10:38:10.046(-5)? (STDERR)                              ^
W20150502-10:38:10.047(-5)? (STDERR) [object Object]
W20150502-10:38:10.047(-5)? (STDERR)     at Object.Future.wait (/home/skaxwng/.meteor/packages/meteor-tool/.1.1.3.4sddkj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
W20150502-10:38:10.047(-5)? (STDERR)     at new MongoConnection (packages/mongo/mongo_driver.js:213:1)
W20150502-10:38:10.047(-5)? (STDERR)     at new      MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:1)
W20150502-10:38:10.047(-5)? (STDERR)     at Object.<anonymous> (packages/mongo/remote_collection_driver.js:38:1)
W20150502-10:38:10.047(-5)? (STDERR)     at Object.defaultRemoteCollectionDriver (packages/underscore/underscore.js:750:1)
W20150502-10:38:10.048(-5)? (STDERR)     at new Mongo.Collection (packages/mongo/collection.js:98:1)
W20150502-10:38:10.048(-5)? (STDERR)     at app/conmongo.js:27:8
W20150502-10:38:10.048(-5)? (STDERR)     at app/conmongo.js:29:3
W20150502-10:38:10.048(-5)? (STDERR)     at /home/skaxwng/meteor/conmongo/.meteor/local/build/programs/server/boot.js:222:10
W20150502-10:38:10.048(-5)? (STDERR)     at Array.forEach (native)
=> Exited with code: 8

我不知道我的应用是否连接到 mongo。我对此没有任何错误。

有人可以帮我解决这个问题吗?谢谢!

【问题讨论】:

  • 您是否在 AWS-EC2 安全部分打开了 2700 端口?
  • 糟糕,我忘记打开端口了。谢谢!

标签: mongodb meteor amazon-ec2


【解决方案1】:

确保在AWS安全规则中打开了27000端口,然后可以使用mongo hostname:port/database -u username -p password命令验证MONGO_URL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 2020-02-12
    • 2018-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多