Failed to start mongod.service: Unit mongod.service not found

前端 未结 25 1486
误落风尘
误落风尘 2020-12-07 14:43

I follow all the steps mention in MongoDB installation documents for Ubuntu 16.04.

Steps 1:

sudo apt-key adv --keyserv         


        
相关标签:
25条回答
  • 2020-12-07 15:17

    In some cases for some security reasons the unit would be marked as masked. This state is much stronger than being disabled in which you cannot even start the service manually.

    to check this, run the following command:

        systemctl list-unit-files | grep mongod
    

    if you find out something like this:

        mongod.service                         masked
    

    then you can unmask the unit by:

        sudo systemctl unmask mongod
    

    then you may want to start the service:

        sudo systemctl start mongod
    

    and to enable auto-start during system boot:

        sudo systemctl enable mongod
    

    However if mongodb did not start again or was not masked at all, you have the option to reinstall it this way:

        sudo apt-get --purge mongo*
        sudo apt-get install mongodb-org
    

    thanks to @jehanzeb-malik

    0 讨论(0)
  • 2020-12-07 15:18

    The second step of mongo installation is

    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
    

    Instead of this command do it manually

    1. cd /etc/apt/
    2. nano sources.list
    3. Write it deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse

    And save the file,

    Continue all process as in installation docs

    It works for me:

    0 讨论(0)
  • 2020-12-07 15:19

    Just try with this command:

    $ sudo systemctl enable mongod
    
    0 讨论(0)
  • 2020-12-07 15:19

    For those that run into this and end up on this answer, as I did, where they got this error during uninstall orupgrade and Ubuntu keeps failing to uninstall the previous because the service doesn't exist this one line will get you past that and allow the uninstall or upgrade to continue.

    sudo touch /lib/systemd/system/mongod.service
    
    0 讨论(0)
  • 2020-12-07 15:20
    $service mongodb start
    $service mongodb status
    

    the status is active when I started using above command

    0 讨论(0)
  • 2020-12-07 15:21

    [Solution]

    Just type

    sudo mongod
    

    It will work.

    0 讨论(0)
提交回复
热议问题