如何解决因意外造成Mongodb服务非正常关闭且造成Mongod服务无法正常启动?


  • 註冊用戶

    我们在使用mongodb时,经常会遇到mongodb服务非正常关闭而无法启动的问题,解决此类问题只需要删除data目录下的*.lock文件,然后再启动Mongod服务就可以了。


  • Lv 1

    1.首先删除/var/lib/mongo/目录下的mongod.lock文件,具体命令如下:
    rm /var/lib/mongo/mongod.lock  

    2.已repair方式启动mongodb,具体命令如下:
    mongod -f /etc/mongod.conf --repair  

    Fri Jan 24 10:38:39.112   
    Fri Jan 24 10:38:39.113 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.  
    Fri Jan 24 10:38:39.114   
    about to fork child process, waiting until server is ready for connections.  
    forked process: 2237  
    all output going to: /var/log/mongo/mongod.log  
    child process started successfully, parent exiting  

    3.在启动一次mongodb,具体命令如下:
    mongod -f /etc/mongod.conf  
    Fri Jan 24 10:41:13.664   
    Fri Jan 24 10:41:13.665 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.  
    Fri Jan 24 10:41:13.666   
    about to fork child process, waiting until server is ready for connections.  
    forked process: 2253  
    all output going to: /var/log/mongo/mongod.log  
    child process started successfully, parent exiting  

    4.查看进程,如果存在mongodb进程,即代表修复成功,具体命令如下:

    ps -ef | grep mongo  
    root      2253     1  2 10:41 ?        00:00:02 mongod -f /etc/mongod.conf  
    root      2268  2079  0 10:43 pts/0    00:00:00 grep mongo  


  • 註冊用戶

    @leo

    讚~ 以後會用到,收藏~


  • 註冊用戶

    之前還滿常遇到這問題,有詳細解決方法,收藏一下,感謝。


登录后回复
 

与 萌阔论坛 的连接断开,我们正在尝试重连,请耐心等待