一、MongoDB报错内容以及解决
这是输入mongo启动时的报错
[root@g3dhkzznakmqafv5-1029528 mongodb]# Error: coul-bash: connecting: command not found
.1:27017 :: caused by :: Connection refused :ction attempt failed: SocketException: Error connecting to 127.0.0
[1]+ Exit 127 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
Change the permission of .sock file.
接下来我们查看MongoDB日志的报错
"ctx":"SignalHandler","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2021-11-14T21:50:59.901+08:00"},"s":"I", "c":"NETWORK", "id":23017, "ctx":"listener","msg":"removing socket file","attr":{"path":"/tmp/mongodb-27017.sock"}}
{"t":{"$date":"2021-11-14T21:50:59.901+08:00"},"s":"I", "c":"NETWORK", "id":4784905, "ctx":"SignalHandler","msg":"Shutting down the global connection pool"}
解决方案
上面日志已经说了移除/tmp目录下的mongodb-27017.sock
这里说一下你切换到tmp目录下查看mongodb-xxx.sock文件
移除mongodb-27017.sock文件就可以了,然后重新启动 OK成功
如果你尝试过切换端口,将所有mongodb-xxx.sock文件移除