MongoDB数据库启动失败
  TEZNKK3IfmPf 2023年11月13日 41 0

自己的云转码服务器用到了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 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月13日 0

暂无评论

推荐阅读
  TEZNKK3IfmPf   2024年05月31日   26   0   0 sqlite数据库
  TEZNKK3IfmPf   2024年05月31日   31   0   0 数据库mysql
  TEZNKK3IfmPf   2024年05月31日   27   0   0 数据库mysql
TEZNKK3IfmPf