MongoDB エラー「ERROR: child process failed, exited with」が発生した場合の対処法

MongoDB エラー「ERROR: child process failed, exited with」が発生した場合の対処法

MongoDBで、エラー「ERROR: child process failed, exited with」が発生した場合の対処法を記述してます。

環境

  • OS Rocky Linux release 8.4 (Green Obsidian)
  • MongoDB 5.0.2

エラー全文

MongoDB起動時に発生。

sudo systemctl start mongod

ステータス確認

sudo systemctl status mongod

<出力結果>
● mongod.service - MongoDB Database Server
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2021-08-27 09:41:17 JST; 2min 52s ago
     Docs: https://docs.mongodb.org/manual
  Process: 798586 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
  Process: 798584 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 798583 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 798581 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

 8月 27 09:41:14 localhost.localdomain systemd[1]: Starting MongoDB Database Server...
 8月 27 09:41:14 localhost.localdomain mongod[798586]: about to fork child process, waiting until server is ready for connections.
 8月 27 09:41:14 localhost.localdomain mongod[798586]: forked process: 798589
 8月 27 09:41:17 localhost.localdomain mongod[798586]: ERROR: child process failed, exited with 14
 8月 27 09:41:17 localhost.localdomain mongod[798586]: To see additional information in this output, start without the "--fork" option.
 8月 27 09:41:17 localhost.localdomain systemd[1]: mongod.service: Control process exited, code=exited status=14
 8月 27 09:41:17 localhost.localdomain systemd[1]: mongod.service: Failed with result 'exit-code'.
 8月 27 09:41:17 localhost.localdomain systemd[1]: Failed to start MongoDB Database Server.

ログ確認。socketがうまくいってないっぽい

sudo tail /var/log/mongodb/mongod.log

<出力結果>
{"t":{"$date":"2021-08-27T09:41:17.334+09:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Rocky Linux release 8.4 (Green Obsidian)","version":"Kernel 4.18.0-305.7.1.el8_4.x86_64"}}}
{"t":{"$date":"2021-08-27T09:41:17.334+09:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"/etc/mongod.conf","net":{"bindIp":"127.0.0.1","port":27017},"processManagement":{"fork":true,"pidFilePath":"/var/run/mongodb/mongod.pid","timeZoneInfo":"/usr/share/zoneinfo"},"storage":{"dbPath":"/var/lib/mongo","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"/var/log/mongodb/mongod.log"}}}}
{"t":{"$date":"2021-08-27T09:41:17.334+09:00"},"s":"E",  "c":"NETWORK",  "id":23024,   "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}}
{"t":{"$date":"2021-08-27T09:41:17.334+09:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":960}}
{"t":{"$date":"2021-08-27T09:41:17.334+09:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}

対処法

一度、対象のsocket file「/tmp/mongodb-27017.sock」を削除する

sudo rm /tmp/mongodb-27017.sock

これで自分の場合は、うまくいきました。