Mongodb is not starting in ubuntu

前端 未结 2 1092
甜味超标
甜味超标 2021-01-05 11:07

I am having a weird problem with mongodb after installation it is ending with a message

invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
dpkg         


        
相关标签:
2条回答
  • 2021-01-05 11:29

    The issue is that you are trying to install a version packaged for Upstart init services, but Debian Squeeze still uses SysV init by default.

    There is a note on this in the install docs: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian-or-ubuntu-linux/#installing-mongodb

    If you are using Debian or Ubuntu that uses SysV style init process, use the following line:

    deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen
    
    0 讨论(0)
  • 2021-01-05 11:47

    This means that you need to create mongodb start script in /etc/init.d/

    Try this script

    #!/bin/bash
    #
    # mongodb     Startup script for the mongodb server
    #
    # chkconfig: - 64 36
    # description: MongoDB Database Server
    #
    # processname: mongodb
    #
    
    # Source function library
    . /lib/lsb/init-functions 
    
    if [ -f /etc/sysconfig/mongodb ]; then
        . /etc/sysconfig/mongodb
    fi
    
    prog="mongod"
    mongod="/usr/local/mongodb/bin/mongod"
    RETVAL=0
    
    start() {
        echo -n $"Starting $prog: "
        daemon $mongod "--fork --logpath /var/log/mongodb.log --logappend 2>&1 >>/var/log/mongodb.log"
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
    }
    
    stop() {
        echo -n $"Stopping $prog: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
    }
    
    reload() {
        echo -n $"Reloading $prog: "
        killproc $prog -HUP
        RETVAL=$?
        echo
        return $RETVAL
    }
    
    case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        restart)
            stop
            start
            ;;
        condrestart)
            if [ -f /var/lock/subsys/$prog ]; then
                stop
                start
            fi
            ;;
        reload)
            reload
            ;;
        status)
            status $mongod
            RETVAL=$?
            ;;
        *)
            echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
            RETVAL=1
    esac
    
    exit $RETVAL
    

    after type in terminal:

    sudo chmod +x /etc/init.d/mongodb
    sudo /etc/init.d/mongodb start
    ps -A | grep mongod
    
    0 讨论(0)
提交回复
热议问题