【发布时间】:2015-08-25 02:02:51
【问题描述】:
我从 AWS(具体来说是 Bitnami)购买了 MEAN 技术堆栈,并且一直在热切地尝试学习如何部署我的第一个节点应用程序。但是,实际上让我的 mongo 连接正常工作时,我遇到了很多困难。 我已阅读文档并尝试了各种方法来解决以下问题
root 管理员密码已重置。这是我使用正确的用户名和密码对的证据
> bitnami@ip-172-31-43-127:~/edupal$ sudo mongo admin --username root --password
pwdremoved
MongoDB shell version: 3.0.3
connecting to: /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017/admin
Server has startup warnings:
2015-06-09T20:11:33.967+0000 I CONTROL [initandlisten]
2015-06-09T20:11:33.967+0000 I CONTROL [initandlisten] ** NOTE: This is a 32 bi
t MongoDB binary.
2015-06-09T20:11:33.967+0000 I CONTROL [initandlisten] ** 32 bit builds a
re limited to less than 2GB of data (or less with --journal).
2015-06-09T20:11:33.967+0000 I CONTROL [initandlisten] ** See http://doch
ub.mongodb.org/core/32bit
2015-06-09T20:11:33.967+0000 I CONTROL [initandlisten]
> show dbs
admin 0.078GB
local 0.078GB
users 0.078GB
> use users
switched to db users
> db.myCollection.find()
{ "_id" : ObjectId("5578c11040a096b7fef84aad"), "name" : "Bill", "score" : "9" }
到目前为止,我相信我在资历方面的信誉良好。这是我连接到我的数据库的方式
// Connect to MongoDB
mongoose.createConnection('mongodb://root:pwdremoved@/opt/bitnami/mongodb/tmp/
mongodb-27017.sock/admin');
mongoose.connection.once('open', function() {
// Load the models.
app.models = require('./models/index');
// Load the routes.
var routes = require('./routes');
_.each(routes, function(controller, route) {
app.use(route, controller(app, route));
});
console.log('Listening on port 3000...');
app.listen(8080);
});
我按照教程here
我不断收到此错误
bitnami@ip-172-31-43-127:~/edupal$ npm start
> app@0.0.0 start /home/bitnami/edupal
> node ./bin/www
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [/opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017]
at null.<anonymous> (/home/bitnami/edupal/node_modules/mongoose/node_modules
/mongodb/lib/mongodb/connection/server.js:555:74)
at emit (events.js:118:17)
at null.<anonymous> (/home/bitnami/edupal/node_modules/mongoose/node_modules
/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at emit (events.js:110:17)
at Socket.<anonymous> (/home/bitnami/edupal/node_modules/mongoose/node_modul
es/mongodb/lib/mongodb/connection/connection.js:534:10)
at Socket.emit (events.js:107:17)
at net.js:459:14
at process._tickCallback (node.js:355:11)
npm ERR! Linux 3.13.0-53-generic
npm ERR! argv "/opt/bitnami/nodejs/bin/.node.bin" "/opt/bitnami/nodejs/bin/npm"
"start"
npm ERR! node v0.12.4
npm ERR! npm v2.11.1
npm ERR! code ELIFECYCLE
npm ERR! app@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.0.0 start script 'node ./bin/www'.
npm ERR! This is most likely a problem with the app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/www
npm ERR! You can get their info via:
npm ERR! npm owner ls app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/bitnami/edupal/npm-debug.log
我不确定自己做错了什么,并尝试了许多连接到 MongoDB 的变体……我已经卡了两天了。
【问题讨论】:
标签: node.js mongodb mongoose mean-stack