Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 11 - Install MongoDB

This tutorial will show you how to install MongoDB 6.x on Debian 11.

Steps

Install MongoDB From Repository

sudo apt update && sudo apt install wget gnupg -y \
  && wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add - \
  && echo "deb http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list \
  && sudo apt update \
  && sudo apt install -y mongodb-org mongodb-org-server mongodb-org-database mongodb-org-mongos mongodb-org-shell mongodb-org-tools

Start And Enable MongoDB Service

sudo systemctl start mongod
sudo systemctl enable mongod

Check Version

mongod --version

Debugging

Illegal instruction - MongoDB Needs AVX CPU Feature

If you get an error saying illegal instruction when running the mongod --version command, then it's quite likely due to your CPU not having AVX instruction support. If this is the case, and you are running a VM through proxmox, then you may just have to go to the virtual machine in question, and change the CPU type to host as shown below (assuming your host CPU has AVX support, which is probably does):

References

Last updated: 19th July 2023
First published: 9th January 2023

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch