Unable to install mongodb properly on ubuntu 18.04 LTS

前端 未结 14 1331
盖世英雄少女心
盖世英雄少女心 2021-02-03 23:26

I am trying to install mongodb on my Ubuntu 18.04 LTS, but it has the following error saying

You might want to run \'apt --fix-broken install\' to correct

相关标签:
14条回答
  • 2021-02-03 23:51

    For Ubuntu version 18.04 LTS, it's better if you will install MongoDB manually.

    I need to go through the following steps to make it run on my Ubuntu 18.04:

    1. Fallow manual installation steps from the following mongo DB manual https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu-tarball/
    2. Download .tgz with the following configurations Download MongoDB
    3. Please note, when you install MongoDB 3.6 or above, it comes up with Curl library of "libcurl4" version and which has some compatibility issues on ubuntu 18.04
    4. Due to this, you will end up resulting following output when try to execute "mongod" command:

    mongod: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by mongod)

    1. To fix this problem, you need to uninstall "libcurl4" dependent library by using the following command

      sudo apt-get remove libcurl4

    2. Then need to install back lower curl lib version (i.e. "libcurl3"), as mongo expects it on ubuntu version "18.04"

      sudo apt-get install libcurl3

    3. You may need to use "sudo" to fork the data and log directories with the installation if it fails with the manual steps

      sudo mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork

    4. you can run "mongo" command now to see the mongo shell running.

    It works for me.

    0 讨论(0)
  • 2021-02-03 23:51

    For me on Pop_OS Linux 20.04 LTS helped:

    1. $ sudo apt-get purge mongodb*

    Then creating /etc/apt/sources.list.d/mongodb-org-4.4.list file for Ubuntu 18.04 (Bionic) via this command:

    1. $ 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 Ubuntu 20.04 (Focal)

    After that install mongodb-org:

    1. $ sudo apt-get update
      $ sudo apt-get install -y mongodb-org

    And start mongodb service:

    1. $ sudo systemctl start mongod
    0 讨论(0)
  • 2021-02-03 23:53

    Uninstall and remove any Mongo packages.

    $ sudo apt-get purge mongodb-org*
    

    Check if related directories removed

    $ sudo rm -r /var/log/mongodb
    $ sudo rm -r /var/lib/mongodb
    

    Recheck for autoremove any remaining mongo packages

    $ sudo apt-get autoremove
    

    Configure your directory

    $ sudo dpkg --configure -a
    

    Force install anything required

    $ sudo apt-get install -f
    

    Install from official site: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

    Finally restart your Ubuntu and check status of Mogodb server as you did earlier.

    0 讨论(0)
  • 2021-02-03 23:59

    The easiest way to install MongoDB and use the mongod command on ubuntu 18.04.

    1. Update the packages list.

        $ sudo apt update
    

    2. Install the MongoDB.

        $ sudo apt install -y mongodb
    

    3. Check the service's status.

        $ sudo systemctl status mongodb
    

    3a. You should see

        ● mongodb.service - An object/document-oriented database
          Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor 
          preset:enabled)
          Active: active (running) since Sat 2019-03-11 10:45:01 UTC; 4min 13s 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
    

    4. To allow access to MongoDB on its default port 27017

         $ sudo ufw allow 27017
    

    5. Check status

         $ sudo ufw status
    

    5a. You should see

         Status: active
         To                         Action      From
         --                         ------      ----
         27017                      ALLOW       Anywhere
         27017 (v6)                 ALLOW       Anywhere (v6)
    

    5b. If it returns inactive

         $ sudo ufw enable
    
         Output:
         Firewall is active and enabled on system startup.
    

    6. Check the / directory to see if there is a data/db directory, if not:

         $ sudo mkdir -p /data/db
    

    7. To run the mongod first you need stop mongodb:

         $ sudo systemctl stop mongodb
    

    8. Finally, you can run the mongod:

         $ sudo mongod
    

    I hope that I helped

    0 讨论(0)
  • 2021-02-04 00:00

    If you need to install mongodb binary (Manually) to your Ubuntu 18.04 LTS (Bionic). You need to download mongodb .tgz file from this link .

    1) Download it to your ~/Downloads folder and moveit to home directory by typing mv Downloads/mongodb-linux-x86_64-ubuntu1804-4.0.4.tgz ~/

    2) Then unter it by typing tar -zxvf mongodb-linux-x86_64-ubuntu1804-4.0.4.tgz place it here (Home directory /home/). Dont move it from here.

    3) Then make a directory at /data/db location and give write permission to thatdirectory.

    sudo mkdir -p /data/db
    
    sudo chmod -R 777 /data/db
    

    4) Now, this is the tricky area. Make sure u r in hme directory by typing pwd (Present Working Directory)

    pwd 
    

    it will show

    /home/<your user name>
    

    Then type

    ls -al

    This command will show up all hiddenfile at home directory and search for

    ~/.bashrc

    5) Edit the .bashrc file and write

    export PATH=mongodb-linux-x86_64-ubuntu1804-4.0.4/bin:$PATH
    

    and save the file type source ./bashrc

    Then type echo $PATH at terminal it will display ~/mongodb-linux-x86_64-ubuntu1804-4.0.4/bin:/home/xenon/.nvm/versions/node/v10.15.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

    6) Now at terminal type mongo --nodb it will show MongoDB shell version v4.0.4

    From here , you are all set, go ahead and enjoy mongodb installation. This istallation is bit complex but by this method you can easily control the version of mongodb and use it as per your need.

    7) Then start mongod

    >sudo mkdir -p /var/log && sudo chmod -R 777 /var/log
    >mongod --port 27017 --dbpath /data/db --logpath /var/log/local.log --fork
    >mongo --port 27017
    
    0 讨论(0)
  • 2021-02-04 00:01

    You need to first uninstall the mongodb, you can use:

    sudo apt-get purge mongodb-org*
    

    After this, install mongodb through the following commands:

    sudo apt-get install mongodb
    

    And then update:

    sudo apt-get update
    

    You are done with the installation of mongodb. You can check it by using the below command:

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