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

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

    You can repair

    $ sudo rm /var/lib/mongodb/mongod.lock
    $ mongod --repair
    $ sudo service mongodb start
    

    For Stop

    $ sudo service mongodb stop
    

    For Restart-

    $ sudo service mongodb restart
    

    For Status-

    $ sudo service mongodb status
    
    0 讨论(0)
  • 2020-12-07 15:12

    You are missing a 'b' I think?

    sudo service mongod start
    

    should be

    sudo service mongodb start
    

    I think this is the case?

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

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

    If you are following the official doc and are coming across with the error above that means mongod.service is not enabled yet on you machine (I am talking about Ubuntu 16.04). You need to do that using following command

    sudo systemctl enable mongod.service
    

    Now you can start mongodb using the following command

    sudo service mongod start
    
    0 讨论(0)
  • 2020-12-07 15:14

    Try this: sudo systemctl start mongod and to check whether its running use sudo systemctl status mongod

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

    I got the same error for a long while, tried almost all installation isntruciton on google but could not find te answer...

    I followed the instructions from https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ but keep getting the error Failed to start mongod.service: Unit mongod.service not found

    I firstly installed using: sudo apt-get install -y mongodb-org Then noticed that wher I run:

    $ sudo apt-get install -y mongodb-org
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      mongodb-org-mongos mongodb-org-shell mongodb-org-tools
    The following NEW packages will be installed
      mongodb-org mongodb-org-mongos mongodb-org-shell mongodb-org-tools
    0 to upgrade, 4 to newly install, 0 to remove and 46 not to upgrade.
    Need to get 0 B/40.1 MB of archives.
    After this operation, 178 MB of additional disk space will be used.
    Selecting previously unselected package mongodb-org-shell.
    (Reading database ... 379307 files and directories currently installed.)
    Preparing to unpack .../mongodb-org-shell_4.0.3_amd64.deb ...
    Unpacking mongodb-org-shell (4.0.3) ...
    Selecting previously unselected package mongodb-org-mongos.
    Preparing to unpack .../mongodb-org-mongos_4.0.3_amd64.deb ...
    Unpacking mongodb-org-mongos (4.0.3) ...
    Selecting previously unselected package mongodb-org-tools.
    Preparing to unpack .../mongodb-org-tools_4.0.3_amd64.deb ...
    Unpacking mongodb-org-tools (4.0.3) ...
    Preparing to unpack .../mongodb-org_4.0.3_amd64.deb ...
    Unpacking mongodb-org (4.0.3) ...
    Setting up mongodb-org-shell (4.0.3) ...
    Setting up mongodb-org-mongos (4.0.3) ...
    Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
    Setting up mongodb-org-tools (4.0.3) ...
    Setting up mongodb-org (4.0.3) ...
    
    
    $ mongod --version
    db version v2.6.12
    2018-10-26T12:03:12.362+0200 git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a
    

    The db version was 2.6.12 instead of the latest one 4.0.3. So make sure you dont have mongodb-org-server already installed, if yes, then make sure you uupdate it to your target version (as indicated @https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ -> Step 4 - Install a specific release of MongoDB.)

    target_version = 4.0.3

    sudo apt-get install -y mongodb-org=target_version mongodb-org-server=target_version mongodb-org-shell=target_version mongodb-org-mongos=target_version mongodb-org-tools=target_version

    $ sudo apt-get install -y mongodb-org=4.0.3 mongodb-org-server=4.0.3 mongodb-org-shell=4.0.3 mongodb-org-mongos=4.0.3 mongodb-org-tools=4.0.3
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following NEW packages will be installed
      mongodb-org mongodb-org-mongos mongodb-org-shell mongodb-org-tools
    The following packages will be upgraded:
      mongodb-org-server
    1 to upgrade, 4 to newly install, 0 to remove and 45 not to upgrade.
    Need to get 15.7 MB/55.8 MB of archives.
    After this operation, 217 MB of additional disk space will be used.
    Get:1 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org-server amd64 4.0.3 [15.7 MB]
    Fetched 15.7 MB in 2s (6,289 kB/s)                 
    Selecting previously unselected package mongodb-org-shell.
    (Reading database ... 379306 files and directories currently installed.)
    Preparing to unpack .../mongodb-org-shell_4.0.3_amd64.deb ...
    Unpacking mongodb-org-shell (4.0.3) ...
    **Preparing to unpack .../mongodb-org-server_4.0.3_amd64.deb ...
    Failed to stop mongod.service: Unit mongod.service not loaded.
    invoke-rc.d: initscript mongod, action "stop" failed.
    dpkg: warning: old mongodb-org-server package pre-removal script subprocess returned error exit status 5
    dpkg: trying script from the new package instead ...
    dpkg: ... it looks like that went OK
    Unpacking mongodb-org-server (4.0.3) over (2.6.12) ...**
    Selecting previously unselected package mongodb-org-mongos.
    Preparing to unpack .../mongodb-org-mongos_4.0.3_amd64.deb ...
    Unpacking mongodb-org-mongos (4.0.3) ...
    Selecting previously unselected package mongodb-org-tools.
    Preparing to unpack .../mongodb-org-tools_4.0.3_amd64.deb ...
    Unpacking mongodb-org-tools (4.0.3) ...
    Preparing to unpack .../mongodb-org_4.0.3_amd64.deb ...
    Unpacking mongodb-org (4.0.3) ...
    Processing triggers for ureadahead (0.100.0-20) ...
    Setting up mongodb-org-shell (4.0.3) ...
    Setting up mongodb-org-mongos (4.0.3) ...
    Processing triggers for systemd (237-3ubuntu10.3) ...
    Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
    Setting up mongodb-org-tools (4.0.3) ...
    Setting up mongodb-org-server (4.0.3) ...
    Installing new version of config file /etc/mongod.conf ...
    Setting up mongodb-org (4.0.3) ...
    

    and after doing this its all working for me :D

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

    The following steps helped me solve the problem of not being able to start mongodb on Ubuntu Server 18.04 LTS

    Step 1: First, remove MongoDB from previous if installed:

    sudo apt remove --autoremove mongodb-org

    Step 2: Remove any mongodb repo list files:

    sudo rm /etc/apt/sources.list.d/mongodb*.list
    sudo apt update
    

    Step 3: Import the public key used by the package management system:

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
    

    Step 4: Create a list file for MongoDB:

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

    Step 5: Reload local package database:

    sudo apt-get update
    

    Step 6: Install the MongoDB packages:

    sudo apt-get install -y mongodb-org
    

    Step 7: Start MongoDB:

    sudo service mongod start
    

    Step 8: Begin using MongoDB:

    mongo
    

    Hope it helps you.

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