我正在尝试在同一台计算机上使用mongo DB在我自己的计算机上设置解析服务器。遵循本教程https://medium.com/@dmathewwws/guide-to-building-your-own-parse-server-aad6568b743d
但我有一些问题,Parse抱怨无法连接到我的数据库。
2017-07-22T17:41:39.888Z - Error generating response. { MongoError: failed to connect to server [localhost:27017] on first connect
at Pool.<anonymous> (/parse/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emitOne (events.js:115:13)
at Pool.emit (events.js:210:7)
at Connection.<anonymous> (/parse/node_modules/mongodb-core/lib/connection/pool.js:260:12)
at Object.onceWrapper (events.js:318:30)
at emitTwo (events.js:125:13)
at Connection.emit (events.js:213:7)
at Socket.<anonymous> (/parse/node_modules/mongodb-core/lib/connection/connection.js:162:49)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
name: 'MongoError',
message: 'failed to connect to server [localhost:27017] on first connect' }
Mongo DB似乎在27017上运行。
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 112 24024 3200/mongod
我也可以通过命令行连接,
mongo mongodb://username:pwd@localhost:27017/myDB
MongoDB shell version: 3.2.15
connecting to: mongodb://username:pwd@localhost:27017/myDB
> show collections
test
>
这是我的dock文件设置。
environment:
...
DATABASE_URI: mongodb://username:pwd@localhost:27017/myDB
mongo:
image: mongo:3.2.15
expose:
- "27017"
volumes:
- /mnt/database/mongodb
这个mongodb实际上是在另一卷中。
root@test:/mnt/database# ls -lh
total 20K
drwx------ 2 root root 16K Jul 20 02:34 lost+found
drwxr-xr-x 4 mongodb mongodb 4.0K Jul 22 17:10 mongodb
提前致谢!