Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal instruction (core dumped) mongodb Ubuntu 20.04 LTS

I installed mongodb-org 5.0.2 as per official documentation

Codes i used to install via Terminal given below:

     1.wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

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

     3.sudo apt-get update

     4.sudo apt-get install -y mongodb-org

After installation i started using

     sudo systemctl start mongod

if I use mongod --version command it shows :-

     Illegal instruction (core dumped)         
like image 474
Abdul Wahhab Avatar asked Mar 02 '23 11:03

Abdul Wahhab


1 Answers

  1. Stop the mongod process by issuing the following command:-

    sudo service mongod stop
    
  2. Remove any MongoDB packages that you had previously installed:-

    sudo apt-get purge mongodb-org*
    
  3. Remove MongoDB databases and log files:-

    sudo rm -r /var/log/mongodb
    sudo rm -r /var/lib/mongodb
    
  4. Then reinstall MongoDB 4.4.x

  5. Import the public key used by the package management system:-

    wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
    
  6. The following instruction is for Ubuntu 20.04 (Focal):-

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

    sudo apt-get update
    
  8. Install MongoDB 4.4.x (Now available 4.4.15)

    sudo apt-get install -y mongodb-org=4.4.15 mongodb-org-server=4.4.15 mongodb-org-shell=4.4.15 mongodb-org-mongos=4.4.15 mongodb-org-tools=4.4.15
    
  9. Use mongod --version to check if it is successfully installed

  10. If you encounter any error while using mongod

    sudo mkdir /data
    cd /data
    sudo mkdir db
    sudo pkill -f mongod
    
  11. Then use sudo mongod command.

  12. After long research, it is now working totally fine thanks to this community and Internet.

EDIT:

After following above steps:

if below error occurs:

mongod.service: Failed with result 'exit-code'.

then remove below files and start mongod service again.

sudo rm -rf /tmp/mongodb-27017.sock
sudo service mongod start

More Info

like image 149
Abdul Wahhab Avatar answered Mar 04 '23 00:03

Abdul Wahhab