即使在系统启动时,mongod也无法启动

时间:2017-03-07 04:22:12

标签: mongodb ubuntu-14.04

当我在我的ubuntu 14.04上运行sudo mongod时,它会给出以下错误

mongod --help for help and startup options
Tue Mar  7 09:42:15.992 [initandlisten] MongoDB starting : pid=2870 port=27017 dbpath=/data/db/ 64-bit host=keshav-mohta
Tue Mar  7 09:42:15.992 [initandlisten] db version v2.4.9
Tue Mar  7 09:42:15.992 [initandlisten] git version: nogitversion
Tue Mar  7 09:42:15.992 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Tue Mar  7 09:42:15.992 [initandlisten] allocator: tcmalloc
Tue Mar  7 09:42:15.992 [initandlisten] options: {}
Tue Mar  7 09:42:16.431 [initandlisten] journal dir=/data/db/journal
Tue Mar  7 09:42:16.435 [initandlisten] recover : no journal files present, no recovery needed
Tue Mar  7 09:42:17.587 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Tue Mar  7 09:42:17.587 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Tue Mar  7 09:42:17.587 [websvr] ERROR:   addr already in use
Tue Mar  7 09:42:17.587 [initandlisten] ERROR:   addr already in use
Tue Mar  7 09:42:17.587 [initandlisten] now exiting
Tue Mar  7 09:42:17.587 dbexit: 
Tue Mar  7 09:42:17.587 [initandlisten] shutdown: going to close listening sockets...
Tue Mar  7 09:42:17.587 [initandlisten] shutdown: going to flush diaglog...
Tue Mar  7 09:42:17.587 [initandlisten] shutdown: going to close sockets...
Tue Mar  7 09:42:17.587 [initandlisten] shutdown: waiting for fs preallocator...
Tue Mar  7 09:42:17.587 [initandlisten] shutdown: lock for final commit...
Tue Mar  7 09:42:17.587 [initandlisten] shutdown: final commit...
Tue Mar  7 09:42:17.760 [initandlisten] shutdown: closing all files...
Tue Mar  7 09:42:17.760 [initandlisten] closeAllFiles() finished
Tue Mar  7 09:42:17.760 [initandlisten] journalCleanup...
Tue Mar  7 09:42:17.760 [initandlisten] removeJournalFiles
Tue Mar  7 09:42:17.969 [initandlisten] shutdown: removing fs lock...
Tue Mar  7 09:42:17.969 dbexit: really exiting now

我知道杀死进程的解决方案(sudo killall mongod),然后再次运行命令,但我的问题是:

为什么我刚启动系统时说 addr已经在使用

有什么方法可以让我每天早上都不需要运行2命令来启动mongod服务。

更新

我的猜测是mongo服务在启动时启动,因为我检查了

sudo initctl list | grep mongo

输出

  

mongodb启动/运行,流程1190

现在我执行以下命令在启动时停止mongodb

sudo update-rc.d -f mongodb remove 

输出

  

删除/etc/init.d/mongodb ...

的所有系统启动链接

当使用sudo initctl list进行检查时,它仍会在列表中显示mongodb。甚至我再次启动系统验证?

1 个答案:

答案 0 :(得分:0)

步骤1:有时在全新的终端ctrl + alt + T中启动服务。

步骤2:使用netstat检测端口是否正在运行

netstat -anp | grep mongodPortHere

如果它正在运行,请使用ps aux | grep "mongod" | less for processId并使用kill -9 processId