Advance

2 ways to Configure MongoDB on Almalinux

2 ways to Configure MongoDB on Almalinux

As the volume of data increases worldwide, businesses are looking for new ways to manage data and information. Today, relational databases (SQL) and non-relational databases (NoSQL) are used to manage data. One of the non-relational databases is MongoDB, which is considered the most popular database in the NoSQL group. This article will explain 2 ways to Configure MongoDB on Almalinux. Eldernode website offers economical Linux VPS servers, which can be the best choice if you want to buy.

How to Install MongoDB on Almalinux Server

MongoDB is a free, open-source, and cross-platform database management program that belongs to the category of NoSQL databases. In fact, this tool can manage document-oriented information, and store or retrieve information. It is developed by MongoDB Inc and is written in C++, C, and JavaScript languages. This database uses JSON documents and is released under a combined license of the GNU Affero General Public License and the Apache License.

Recommended Article: How to setup IKev2 on centos 8 complete

1- Installing MongoDB on AlmaLinux

The first step is to add the MongoDB repository. As you know, Almalinux does not include MongoDB packages and you should create the MongoDB repository as shown below:

sudo vim /etc/yum.repos.d/mongodb-org.repo

And add the following configuration to be able to install the latest version:

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

Now update the system repositories using the command below to sync the MongoDB repository with the system:

sudo dnf update

It’s time to install MongoDB on your AlmaLinux. To do this, just run the following command:

sudo dnf install mongodb-org

Press Y and Enter to import the MongoDB GPG key.

You can verify the installation of the MongoDB version with the following command:

mongod --version

Now check the MongoDB status as shown below:

sudo systemctl status mongod

You need to start the MongoDB daemon with the following command:

sudo systemctl start mongod

And enable it using the command below:

sudo systemctl enable mongod

Verify the MongoDB status again to confirm that it has been run:

sudo systemctl status mongod

You can log in to the Mongo shell using the command below:

mongo

2- Managing Databases with MongoDB

The following command will show you the current databases. MongoDB provides a test database by default which is called a test:

> db

You can create a database using the command below:

> use eldernode-db

MongoDB stores data in records called documents and in a JSON-like format. Also, entries exist as key-value pairs.

In this step, create a document and add some data as shown below. Remember to add this on your MongoDB prompt and press Enter:

db.students.insertOne(     { "First Name" : "Marilyn",       "Last_Name" : "Bisson",       "City" : "Piscataway",       "Id No." : 123456,       "Age" : 24     }  )

You can see the documents in your database with the command below:

> show collections

The following command can display the stored data in the documents:

> db.students.find()

If you want to delete the document, enter the following command:

db.students.drop()

That’s it!

Recommended Article: Tutorial make a full backup of Host Cpanel

Conclusion

MongoDB is one of the NoSQL databases that you can use for database management. In this article, we introduced you to MongoDB and taught you how to configure MongoDB on AlmaLinux in 2 ways. I hope this tutorial was useful for you and helps you to install MongoDB on your AlmaLinux. You can contact us in the Comments section if you face any problems or have any questions.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day