Install MongoDB on CentOS 7

  • Last Created On Dec 05, 2024
  • 9
0 0

MongoDB is one of the leading NoSQL databases that is commonly used in modern web applications. This tutorial will walk you through setting up MongoDB on CentOS 7.

Update System (Optional)

You will want to make sure that your server is up-to-date. If you are setting up your VPS for the first time, it should already be up-to-date. However, if you are running a Custom ISO, or installing on an existing VPS, then you can run the following command to do a system update:

yum update

Install MongoDB

With Yum

CentOS is shipped with MongoDB 2.4.9 (this may change in the future). To install it over yum, run the following command:

yum install mongodb

From MongoDB Repository

If you wish to use the latest version of MongoDB, then you will need to setup the official repository on your server. To do so, create a file in /etc/yum.repos.d/mongodb.repo and populate it with the following data:

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

Note: This is for the 64-bit version of CentOS 7. If you have installed the 32-bit version of CentOS 7 using a Custom ISO, you need to change x86_64 to i686.

Once you have saved the file, run the following commands:

yum update
yum install mongodb-org -y

Proceed after the installation has finished.

Setup MongoDB

Start MongoDB by running systemctl start mongod. After the service has started, type mongo into your terminal. If the installation was successful, you will see output similar to the following text.

MongoDB shell version: 2.x.x
connecting to: test
>

Note: Any start-up warnings related to Readahead can be safely ignored. To prevent these warnings, verify that the sectors are “as stated” in the warning by running blockdev –getra /dev/vda1. If the output is greater than 512, run the following commands:

blockdev --setra 512 /dev/vda1
systemctl restart mongod

The warning will now be resolved.

At this point, you are ready to use MongoDB!

Views: 9

Recent Articles

  • How to Install JAX with ROCm Acceleratio...
    95
  • Deploy a PyTorch Workspace on a Vultr Cl...
    71
  • Managing Backup Storage
    81
  • Automating FTP Backups in Windows Server
    71
  • Automating FTP Backups in Linux
    75

Popular Articles

  • Our General Terms & Conditions
    2629
  • Our Privacy Policy
    2473
  • Our Cookies Policy
    275
  • Our Terms of Use
    152
  • How to Install JAX with ROCm Acceleratio...
    95