微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MongoDB数据库启动失败

目录

问题

解决


问题

自己的云转码服务器用到了MongoDB数据库,使用docker部署的有些情况下,转码服务启动时会遇到数据库服务无法伴随启动的现象。

这个时候,就必须依赖自己手动启动数据库服务。

相关的报错信息如下:

0|www  | (node:248) [MONGODB DRIVER] Warning: Current Server discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
0|www  | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|www  | MongoNetworkError: Failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
0|www  |     at Pool.<anonymous> (/root/boffmpeg/node_modules/mongoose/node_modules/mongodb/lib/core/topologies/server.js:438:11)
0|www  |     at emitOne (events.js:116:13)
0|www  |     at Pool.emit (events.js:211:7)
0|www  |     at createConnection (/root/boffmpeg/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:562:14)
0|www  |     at connect (/root/boffmpeg/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:995:11)
0|www  |     at makeConnection (/root/boffmpeg/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:32:7)
0|www  |     at callback (/root/boffmpeg/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:280:5)
0|www  |     at Socket.err (/root/boffmpeg/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:310:7)
0|www  |     at Object.onceWrapper (events.js:315:30)
0|www  |     at emitOne (events.js:116:13)
0|www  |     at Socket.emit (events.js:211:7)
0|www  |     at emitErrorNT (internal/streams/destroy.js:73:8)
0|www  |     at _combinedTickCallback (internal/process/next_tick.js:139:11)
0|www  |     at process._tickCallback (internal/process/next_tick.js:181:9)

类似的报错:

 Failed to get D-Bus connection: Operation not permitted

解决

手动启动MongoDB数据库服务,需要找到该服务的可执行程序和相应的配置文件,然后使用-f参数执行如下命令:

/usr/bin/mongod -f /etc/mongod.conf 

出现successfully信息,表示启动成功。

比如:

[root@731ae35768eb boffmpeg]# /usr/bin/mongod -f /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 3304
child process started successfully, parent exiting

但是,最直接的方式还是在运行容器的时候,指定特殊权限,具体命令可以参考:

docker run -itd --net=host --restart=always --name boffmpeg --privileged=true 0ba8f07ac61d /usr/sbin/init 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐