12

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)         
Abdul Wahhab
  • 768
  • 1
  • 6
  • 12
  • 3
    https://stackoverflow.com/questions/68392064/error-when-running-mongo-image-docker-entrypoint-sh-line-381/68394912#68394912 – D. SM Aug 27 '21 at 19:10
  • 1
    Does this answer your question? [Error when running mongo image - docker-entrypoint.sh: line 381](https://stackoverflow.com/questions/68392064/error-when-running-mongo-image-docker-entrypoint-sh-line-381) – tripleee Aug 29 '21 at 13:12

2 Answers2

34
  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

Abdul Wahhab
  • 768
  • 1
  • 6
  • 12
  • 2
    My endless problems with Mongo core dump version 5 was solved by going back to version 4.4.8 as per your instructions. Thank you. – Eugene van der Merwe Oct 02 '21 at 18:25
  • E: Version '4.4.8' for 'mongodb-org' was not found – VityaSchel Mar 06 '22 at 17:41
  • @VityaSchel - v4.4.8 is an old version and no longer available. There are newer v4.4.x releases though. So long as you don't have a v5 repo configured (in /etc/apt/sources.list.d/) then you could just exclude the '=4.4.8' from each packagename when installing. If you want to see what versions are available, try 'apt policy mongodb-org'. – Jeremy Davis Apr 22 '22 at 07:52
  • I had to do `rm /etc/apt/sources.list/mongo*` to remove old files of previous installations. – Lars Dec 08 '22 at 19:37
  • Important note - don't forget to mark installed packages as upgrade-protected so that next apt upgrade won't upgrade your version of mongodb to the latest version and return all problems. sudo apt-mark hold (sudo apt-mark showhold to list holded packages) – Dmitry Lobov Feb 04 '23 at 20:26
  • @JeremyDavis It now only shows 5.0+ releases which all doesn't seem to work for me – VityaSchel Apr 16 '23 at 13:01
  • v4.4.x is still available, but only for older distros. I.e. if you use Debian 10/Buster or Ubuntu 20.04 you should be good. So either downgrade your OS or upgrade your hardware (or compile MongoDB from source). – Jeremy Davis Apr 16 '23 at 22:57
2

Not the best variant, to downgrade your mongo installation.

Problem cause your host or vm doesnt support an AVX instruction of cpu.

https://www.mongodb.com/community/forums/t/mongodb-community-5-0-12-illegal-instruction-core-dumped-ubuntu-20-04-5-lts/204332

Check if your host supports AVX instruction (lscpu | grep avx), if does, seems you running mongo in vm, check your hypervisor configured to passthrough host cpu features into VM.

If host doesnt support AVX instructions, so downgrade is your choise

none_nfg
  • 21
  • 1