radrss

Your Favorite Blogs In One Place

Viewing post at Addictivetips

How to install MongoDB Community Edition on Linux

Mongo DB Community is the free edition of the Mongo database software. The Community edition is an excellent option for those that don’t want to pay for the “Enterprise” edition but still want to use excellent database software.

In this guide, we’ll show you how to install MongoDB Community Edition on Ubuntu Server, Debian, as well as RedHat (CentOS/RHEL/Oracle), and OpenSUSE server distros.

Ubuntu installation instructions

MongoDB Community Edition is supported on all current LTS versions of Ubuntu. However, only the 64-bit versions of the OS are supported. So, if you plan to use MongoDB Community Edition on Ubuntu Server, be sure you’re on a 64-bit version of the LTS release, or you will not be able to install it.

To start the installation of MongoDB Community Edition, begin by downloading the repo key to Ubuntu. This repo key is required, or Ubuntu will not interact with the MongoDB software repository. Add the key with the command below.

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

After adding the key to your system, you must manually add the MongoDB software repository to your system. There are many ways to do this, but the most efficient way is by executing the add-apt-repository command.

Ubuntu 20.04 LTS

sudo add-apt-repository "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse"

Ubuntu 18.04 LTS

sudo add-apt-repository "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse"

Ubuntu 16.04 LTS

sudo add-apt-repository "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse"

Once the MongoDB Community Edition software repository is added to Ubuntu, the installation’s next step is to update your software sources. To update, run the following apt update command.

sudo apt update

While your Ubuntu system is updating, you should see the MongoDB software repo appear in the list of links Ubuntu checks. When everything is finished, you can install the MongoDB packages.

sudo apt install mongodb-org

Following the installation of MongoDB Community Edition, some configuration and tweaking is required to use it on your server. For more information, check the Ubuntu page on the official website.

Debian installation instructions

MongoDB Community Edition is well supported on Debian and supports Debian 10 (Stable) and Debian 9 (Old Stable). However, MongoDB only supports the 64-bit release of these operating systems, so keep that in mind.

To start installing MongoDB Community Edition on your Debian Linux server, begin by downloading the software repo key to the system and enabling it. The software key is required to interact with the repo, and it won’t work without it.

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

After adding the software key to your computer, you must add the custom MongoDB Community Edition software repository to your Debian system. There are many ways to do this, but add-apt-repository works best and is the least confusing.

Debian 10

sudo add-apt-repository "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main"

Debian 9

sudo add-apt-repository "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.4 main"

Once the new MongoDB software repository is added to your Debian system, you must run the update command. An update will refresh software sources and add the MongoDB repo to the package database.

sudo apt-get update

While the update is happening, you’ll notice “MongoDB” appears in the list of repos that Debian checks. When the process is complete, you can quickly install MongoDB Community Edition on Debian with the command below.

sudo apt-get install mongodb-org

After installing MongoDB Community Edition on Debian, you will need to review some documentation to get the software working. For more information on how to set it up, click here.

RedHat/CentOS/Oracle installation instructions

MongoDB Community Edition is available for RedHat Enterprise Linux 6/7/8 and CentOS 6/7/8. It is also available for Oracle Linux 6/7/8. However, MongoDB only supports the 64-bit versions of these operating systems, so keep that in mind.

To start the installation, you must create a new MongoDB repo file. To do that, execute the touch command below.

sudo touch /etc/yum.repos.d/mongodb-org-4.4.repo 

After creating the new repo file, open up the Nano text editor file for editing purposes. We are using Nano in this guide as it is the most straightforward editor to understand. However, feel free to use your editor if you are an expert.

sudo nano -w /etc/yum.repos.d/mongodb-org-4.4.repo 

Paste the following code into the repo file in the Nano text editor. The code must look identical to the example below, or it may not work!

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

Once the code is added to the new MongoDB repo file, press the Ctrl + O button to save and Ctrl + X to exit. Then, install the latest MongoDB to your system with the command below.

sudo yum install -y mongodb-org

Following the installation of MongoDB Community Edition on RedHat/CentOS/Oracle, you will need to do some configuration to get the software working. For more information, click here.

OpenSUSE Enterprise installation instructions

On OpenSUSE, MongoDB Community Edition is supported on SLES 15 and SLES 12. That said, MongoDB only has support for the 64-bit versions of the operating system. If you are running a 32-bit server, you will need to transition to 64-bit.

To start the installation of MongoDB Community Edtion on SUSE Enterprise, you must import the repo key. The repo key is needed to interact with the MongoDB repo.

sudo rpm --import https://www.mongodb.org/static/pgp/server-4.4.asc

After importing the key, use the zypper addrepo key to add the new MongoDB software repository to your system.

SLES 15

sudo zypper addrepo --gpgcheck "https://repo.mongodb.org/zypper/suse/15/mongodb-org/4.4/x86_64/" mongodb

SLES 12

sudo zypper addrepo --gpgcheck "https://repo.mongodb.org/zypper/suse/12/mongodb-org/4.4/x86_64/" mongodb

Once the MongoDB repo is set up on your SUSE system, the installation of MongoDB Community Edition can begin. Using the zypper command below, install MongoDB.

sudo zypper -n install mongodb-org

You must configure MongoDB Community Edition before attempting to use it on OpenSUSE. For more information, consult the documentation here.

The post How to install MongoDB Community Edition on Linux appeared first on AddictiveTips.