openSUSE

How to Install MongoDB on openSUSE

How_to_Install_MongoDB_on_openSUSE

MongoDB is one of the widely popular document-oriented NoSQL databases. It is designed to store a massive amount of data while also allowing you to work with that data in a very efficient manner. It is used in the development of many modern web applications. It is open-source and written in C++. MongoDB supports a variety of Linux platforms including Ubuntu, Debian, CentOS, RedHat, and openSUSE. It also supports Windows and MacOS.

In this post, we will install MongoDB on openSUSE Leap 15.3 OS.

Installing MongoDB on openSUSE

In the following method, we will install MongoDB on the openSUSE machine by first adding the MongoDB repository. Then we will install MongoDB using the Zypper package manager. Let’s get started.

1. First, you will need to add the GPG key for the MongoDB repository. Execute the command below to add the MongoDB repository’s GPG key to your system:

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

Enter the sudo password.

2. Add MongoDB repository through the command below:

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

If the repository is successfully added, you will see output as shown below:

3. Now in order to install MongoDB on your openSUSE system, execute the command below:

$ sudo zypper install mongodb-org

It will list the MongoDB package and all the dependencies that will be installed alongside it. To continue the operation, hit y and then Enter key.

After MongoDB is installed, you can initiate its service through the command below:

$ sudo systemctl start mongod

To verify if the service has been initiated, execute the command below:

$ sudo systemctl status mongod

If MongoDB service is started, you will see the output as shown below:

After the MongoDB service has been initiated, you can start using it. To start the MongoDB session, execute the command below:

$ mongosh

Manage MongoDB services

If you want to stop the MongoDB service, execute the command below:

$ sudo service mongod stop

To restart the MongoDB service, execute the command below:

$ sudo service mongod restart

If you want to start the MongoDB service automatically at boot, execute the command below:

$ sudo service mongod enable

Uninstall MongoDB

If you no longer need MongoDB installed on your system, you can uninstall it as follows:

1. First, you will need to stop the MongoDB service by executing the command below:

$ sudo service mongod stop

2. To find the list of MongoDB packages that are installed on your openSUSE system, execute the command below:

$ rpm -qa | grep mongodb-org

It will list all the MongoDB packages installed on your system.

3. To remove all the MongoDB packages, execute the command below:

sudo zypper remove mongodb-org-*

4. If you also want to remove MongoDB log files and databases, execute the command below:

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

That is all there is to it! In this post, we covered how to install MongoDB on openSUSE OS through the MongoDB repository. Then we covered how to manage MongoDB services. In the end, we covered how to uninstall MongoDB in case you want to do so.

Similar Posts