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

前端 未结 25 1525
误落风尘
误落风尘 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:05

    I just encountered this on my parrot os and this is how I solved it.

    sudo service mongodb start
    
    0 讨论(0)
  • 2020-12-07 15:05

    Do not remove your db if you already have some data you found useful. Just run the command below and you're good.

    sudo systemctl restart mongodb.service
    
    0 讨论(0)
  • 2020-12-07 15:06

    May be you are using a wrong version of mongodb list file. I faced this problem but it's my mistake when not selecting the right list file for Ubuntu 16.04. The default selected is for Ubuntu 14.04 and it's the reason for my error: "Failed to start mongod.service: Unit mongod.service not found."

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

    Note that if using the Windows Subsystem for Linux, systemd isn't supported and therefore commands like systemctl won't work:

    Failed to connect to bus: No such file or directory

    See Blockers for systemd? #994 on GitHub, Microsoft/WSL.

    The mongo server can still be started manual via mondgod for development of course.

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

    Just follow the below commands. This has worked for me.

    1. Uninstall your mongo completely from your system:

      sudo service mongod stop
      sudo apt-get purge mongodb-org
      sudo rm -r /var/log/mongodb
      sudo rm -r /var/lib/mongodb
      
    2. Now reinstall mongodb using following commands:

      sudo apt update
      sudo apt install -y mongodb**
      

      Note: The database server is automatically started after installation.

    3. Next, let's verify that the server is running and works correctly.

      sudo systemctl status mongodb
      

      You'll see this output:

      mongodb.service - An object/document-oriented database
      Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
      Active: active (running) since Sat 2018-05-26 07:48:04 UTC; 2min 17s ago
      Docs: man:mongod(1)
      Main PID: 2312 (mongod)
      Tasks: 23 (limit: 1153)
      CGroup: /system.slice/mongodb.service
         └─2312 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf**
      
    0 讨论(0)
  • 2020-12-07 15:10

    As per documentation:

    Run this command to reload the daemon:

    sudo systemctl daemon-reload
    

    After this you need to restart the mongod service:

    sudo systemctl start mongod
    

    To verify that MongoDB has started, run:

    sudo systemctl status mongod
    

    To ensure that MongoDB will start following a system reboot, run:

    sudo systemctl enable mongod
    
    0 讨论(0)
提交回复
热议问题