我通过以下方式启动了mongo服务器
brew services restart mongodb@3.4
Stopping `mongodb@3.4`... (might take a while)
==> Successfully stopped `mongodb@3.4` (label: homebrew.mxcl.mongodb@3.4)
==> Successfully started `mongodb@3.4` (label: homebrew.mxcl.mongodb@3.4)
我可以检查它是否确实在运行
brew services list
Name Status User Plist
mongodb@3.4 started root /Library/LaunchDaemons/homebrew.mxcl.mongodb@3.4.plist
但是当我尝试通过标准端口连接它时,它失败了:
lsof -i:27017
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
GUI:
通过cat
结果中列出的plist
文件brew services list
,我得到了mongodb配置文件路径:
cat /Library/LaunchDaemons/homebrew.mxcl.mongodb@3.4.plist
<?xml version="1.0" encoding="UTF-8"?>
...
<string>/usr/local/etc/mongod.conf</string>
...
所以我cat
conf文件:
cat /usr/local/etc/mongod.conf
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
因此,我再次选择系统日志:
cat /usr/local/var/log/mongodb/mongo.log
2018-10-10T11:02:19.071+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-10-10T11:02:19.071+0800 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2018-10-10T11:02:19.071+0800 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2018-10-10T11:02:19.071+0800 I CONTROL [initandlisten] now exiting
2018-10-10T11:02:19.071+0800 I CONTROL [initandlisten] shutting down with code:100
因此lsof -i:27017
未给出任何结果的原因是mongo服务器遇到了一些错误并存在。伤心...
问题就变成了:如何找到导致mongo服务器退出的错误的根源?以及如何解决?谢谢!