How To Install MongoDB on CentOS 7
Introduction
MongoDB is a document-oriented database that is free and open-source. It is classified as a NoSQL database because it does not rely on a traditional table-based relational database structure. Instead, it uses JSON-like documents with dynamic schemas. Unlike relational databases, MongoDB does not require a predefined schema before you add data to a database. You can alter the schema at any time and as often as is necessary without having to setup a new database with an updated schema.
This tutorial guides you through installing MongoDB Community Edition on a CentOS 7 server.
Prerequisites
Before following this tutorial, make sure you have a regular, non-root user with
sudo privileges. You can learn more about how to set up a user with these privileges from our guide, How To Create a Sudo User on CentOS.Step 1 – Adding the MongoDB Repository
The
mongodb-org package does not exist within the default repositories for CentOS. However, MongoDB maintains a dedicated repository. Let's add it to our server.
With the
vi editor, create a .repo file for yum, the package management utility for CentOS 7:
Then, visit the Install on Red Hat section of MongoDB’s documentation and add the repository information for the latest stable release to the file:
Save and close the file.
Before we move on, we should verify that the MongoDB repository exists within the
yum utility. The repolist command displays a list of enabled repositories:output
With the
MongoDB Repository in place, let's proceed with the installation.Step 2 – Installing MongoDB
We can install the
mongodb-org package from the third-party repository using the yum utility.
There are two
Is this ok [y/N]: prompts. The first one permits the installation of the MongoDB packages and the second one imports a GPG key. The publisher of MongoDB signs their software and yum uses a key to confirm the integrity of the downloaded packages. At each prompt, type Y and then press the ENTER key.
Next, start the MongoDB service with the
systemctl utility:
Although we will not use them in this tutorial, you can also change the state of the MongoDB service with the
reload and stop commands.
The
reload command requests that the mongod process reads the configuration file, /etc/mongod.conf, and applies any changes without requiring a restart.Syntax of update method of SimpleJdbcTemplate class
The
stop command halts all running mongod processes.
The
systemctl utility did not provide a result after executing the start command, but we can check that the service started by viewing the end of the mongod.log file with the tail command:
No comments:
Post a Comment
Note: only a member of this blog may post a comment.