I started the mongo server by
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)
And I can check it is really running by
brew services list
Name Status User Plist
mongodb@3.4 started root /Library/LaunchDaemons/homebrew.mxcl.mongodb@3.4.plist
But I when I tried to connect it via the standard port, it fails:
lsof -i:27017
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
the GUI:
By cat the plist file listed in the result of brew services list, I get the mongodb config file path:
cat /Library/LaunchDaemons/homebrew.mxcl.mongodb@3.4.plist
<?xml version="1.0" encoding="UTF-8"?>
...
<string>/usr/local/etc/mongod.conf</string>
...
So I cat the conf file:
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
So again I cat the system log again:
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
So the reason why lsof -i:27017 gives no result is the mongo server met some error and existed. Sad...
So the question becomes: How can I find the root cause the error that mongo server exits? and how to fix it? Thanks!
