使用mongod --config /etc/mongod.conf & 啓動mongodb,而後過段時候後發現本身退出了,檢查log:mongodb
2018-12-29T06:53:15.079+0000 I CONTROL [signalProcessingThread] got signal 1 (Hangup), will terminate after current cmd ends 2018-12-29T06:53:15.079+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture 2018-12-29T06:53:15.080+0000 I STORAGE [conn3] got request after shutdown() 2018-12-29T06:53:15.082+0000 I CONTROL [signalProcessingThread] now exiting 2018-12-29T06:53:15.082+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets... 2018-12-29T06:53:15.082+0000 I NETWORK [signalProcessingThread] closing listening socket: 6 2018-12-29T06:53:15.082+0000 I NETWORK [signalProcessingThread] closing listening socket: 7 2018-12-29T06:53:15.082+0000 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock 2018-12-29T06:53:15.082+0000 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog... 2018-12-29T06:53:15.082+0000 I NETWORK [signalProcessingThread] shutdown: going to close sockets...
是收到關閉信號,正常關閉的。
google以後發現是由於沒有-fork,因此當shell退出的時候,mongodb也退出了。
因此,須要加上--fork。啓動server模式shell
mongod --config /etc/mongod.conf --fork
搞定。socket