我曾经在Ubuntu 20.04上安装了mongoDB(非官方包)。我决定改用官方的。(4.4版)首先,两个包都被混淆了,但是在擦掉旧的之后,安装成功了。
但是,当我尝试运行mongod服务时,它失败了,并显示如下:
myubuntu:~$ sudo systemctl start mongod
myubuntu:~$ (no prompts, all is ok so far)
myubuntu:~$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2021-06-04 01:11:27 EDT; 14s ago
Docs: https://docs.mongodb.org/manual
Process: 21446 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
Main PID: 21446 (code=exited, status=14)
jun 04 01:11:27 robb systemd[1]: Started MongoDB Database Server.
jun 04 01:11:27 robb systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
jun 04 01:11:27 robb systemd[1]: mongod.service: Failed with result 'exit-code'.
和:
myubuntu:~$ mongod
{"t":{"$date":"2021-06-04T01:18:08.279-04:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2021-06-04T01:18:08.283-04:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2021-06-04T01:18:08.283-04:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2021-06-04T01:18:08.284-04:00"},"s":"I", "c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":21483,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"robb"}}
{"t":{"$date":"2021-06-04T01:18:08.284-04:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.6","gitVersion":"72e66213c2c3eab37d9358d5e78ad7f5c1d0d0d7","openSSLVersion":"OpenSSL 1.1.1f 31 Mar 2020","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2004","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2021-06-04T01:18:08.284-04:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"20.04"}}}
{"t":{"$date":"2021-06-04T01:18:08.284-04:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{}}}
{"t":{"$date":"2021-06-04T01:18:08.285-04: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-06-04T01:18:08.285-04:00"},"s":"F", "c":"-", "id":23091, "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":40486,"file":"src/mongo/transport/transport_layer_asio.cpp","line":919}}
{"t":{"$date":"2021-06-04T01:18:08.285-04:00"},"s":"F", "c":"-", "id":23092, "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
我还想提一下,我已经仔细按照步骤进行了操作,并且多次擦除和重新安装包,并按照解决方案中的建议(参见mongoDB官方解决方案)更新为(sudo apt-get update)
我发现了一个相关问题,同一作者找到了解决方案,请点击这里查看:
附带说明一下,如果您有相同的错误,并且提供的解决方案不起作用,请按照链接尝试此答案,但要特别注意删除mongoDB创建的lib和日志文件,
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
删除这些文件非常重要。
另外,尝试使用sudo service命令而不是sudo systemctl命令来启动mongod
MongoDB的故障排除不包括这些步骤,它们对我来说是真正的不同。