想了想还是把这个问题单独写个blog。
之前听说如果用ill -9 mongod之后mongodb服务无法开启问题的
解决方法是删除/data下的mongod.lock就能够正常使用了。
但是用mongodb2.6在fedora下实验的结果是kill -9并没有导致服务无法被开启。并且,pkill,kill -9都会导致mongo.lock的生成。并且,pkill和kill -9会将杀死mongod的主进程pid写在mongod.lock中,无论是是杀死mongod还是mongod的pid。
这或许是一件好事。不过早先版本的mongodb我没有实验,并且在其他服务器版本的linux(如centos等)或Ubuntu系列的linux上会不会出现“kill -9 mongod之后mongodb服务无法开启问题的”我没有实验,如果有人实验过请留言分享您的实验结果谢谢!
我的例子附上:
[neil@neilhost bin]$ sudo ./mongod --dbpath=/usr/local/mongodb/data/ --logpath=/usr/local/mongodb/dblogs --fork
about to fork child process, waiting until server is ready for connections.
forked process: 5302
child process started successfully, parent exiting
[neil@neilhost bin]$ pstree -p |grep mongod
|-mongod(5302)-+-{mongod}(5303)
| |-{mongod}(5304)
| |-{mongod}(5305)
| |-{mongod}(5308)
| |-{mongod}(5309)
| |-{mongod}(5310)
| |-{mongod}(5311)
| |-{mongod}(5312)
| `-{mongod}(5313)
[neil@neilhost bin]$ sudo kill -9 5302
[sudo] password for neil:
[neil@neilhost bin]$ pstree -p |grep mongod
[neil@neilhost bin]$
[neil@neilhost bin]$ sudo ./mongod --dbpath=/usr/local/mongodb/data/ --logpath=/usr/local/mongodb/dblogs --fork
about to fork child process, waiting until server is ready for connections.
forked process: 5373
child process started successfully, parent exiting
[neil@neilhost bin]$ pstree -p |grep mongod
|-mongod(5373)-+-{mongod}(5374)
| |-{mongod}(5375)
| |-{mongod}(5376)
| |-{mongod}(5380)
| |-{mongod}(5381)
| |-{mongod}(5382)
| |-{mongod}(5383)
| |-{mongod}(5384)
| `-{mongod}(5385)
[neil@neilhost bin]$ cd ../data
[neil@neilhost data]$ ls
journal local.0 local.ns mongod.lock
[neil@neilhost data]$ sudo rm -rf *