我一直在尝试在我的AWS EC2实例上安装Mongodb以使用我编写的Node.js服务器。
按照this指南,我能够“安装”monogdb
但是我设置为mongod和mongo路径的别名,因为我退出时路径被丢弃了
alias mongod='/home/ec2-user/mongodb/mongodb-linux-x86_64-3.0.0/bin/mongod'
alias mongo='/home/ec2-user/mongodb/mongodb-linux-x86_64-3.0.0/bin/mongo'
我可以使用这个别名启动mongo服务器没问题。
但是当我运行node server.js时,我得到了
/home/ec2-user/project/node_modules/mongodb/lib/mongodb/connection/base.js:246
throw message;
^
AssertionError: {"name":"MongoError","ok":0,"errmsg":"ns not found"} == null
at /home/ec2-user/project/server.js:38:13
at /home/ec2-user/project/node_modules/mongodb/lib/mongodb/db.js:1217:20
at /home/ec2-user/project/node_modules/mongodb/lib/mongodb/db.js:1194:16
at /home/ec2-user/project/node_modules/mongodb/lib/mongodb/db.js:1903:9
at Server.Base._callHandler (/home/ec2-user/project/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
at /home/ec2-user/project/node_modules/mongodb/lib/mongodb/connection/server.js:487:18
at MongoReply.parseBody (/home/ec2-user/project/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at null.<anonymous> (/home/ec2-user/project/node_modules/mongodb/lib/mongodb/connection/server.js:445:20)
at emit (events.js:95:17)
at null.<anonymous> (/home/ec2-user/project/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13)
我已经搜索了一下这个错误,但找不到任何东西。奇怪的是我可以在屏蔽的mongod进程中看到传入的连接。就这样
2015-03-29T20:40:45.782+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:37394 #34 (1 connection now open)
2015-03-29T20:40:45.782+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:37395 #35 (2 connections now open)
2015-03-29T20:40:45.783+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:37396 #36 (3 connections now open)
2015-03-29T20:40:45.783+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:37397 #37 (4 connections now open)
2015-03-29T20:40:45.784+0000 I NETWORK [initandlisten] connection accepted from 127.0.0.1:37398 #38 (5 connections now open)
2015-03-29T20:40:46.721+0000 I COMMAND [conn35] CMD: drop data.page-1
2015-03-29T20:40:46.749+0000 I COMMAND [conn36] CMD: drop data.page-2
2015-03-29T20:40:46.772+0000 I COMMAND [conn37] CMD: drop data.page-4
2015-03-29T20:40:46.803+0000 I COMMAND [conn38] CMD: drop data.page-3
2015-03-29T20:40:46.822+0000 I COMMAND [conn34] CMD: drop data.page-5
2015-03-29T20:40:46.829+0000 I NETWORK [conn34] end connection 127.0.0.1:37394 (4 connections now open)
2015-03-29T20:40:46.829+0000 I NETWORK [conn35] end connection 127.0.0.1:37395 (3 connections now open)
2015-03-29T20:40:46.829+0000 I NETWORK [conn36] end connection 127.0.0.1:37396 (2 connections now open)
2015-03-29T20:40:46.829+0000 I NETWORK [conn37] end connection 127.0.0.1:37397 (1 connection now open)
2015-03-29T20:40:46.829+0000 I NETWORK [conn38] end connection 127.0.0.1:37398 (0 connections now open)
答案 0 :(得分:0)
错误ns not found
表示某些操作是在不存在的命名空间(ns)上运行的,就像您打算在database.collection
上操作,而是尝试在database.colletcion
上操作。根据代码中的错误发生位置,这是否有意义?如果没有,你可以从server.js发布有问题的行吗?