{"id":965,"date":"2019-12-10T11:30:53","date_gmt":"2019-12-10T04:30:53","guid":{"rendered":"https:\/\/zinisoft.net\/?p=965"},"modified":"2024-05-29T07:42:16","modified_gmt":"2024-05-29T07:42:16","slug":"how-to-install-mongodb-4-x-on-centos","status":"publish","type":"post","link":"https:\/\/zinisoft.net\/vi\/how-to-install-mongodb-4-x-on-centos\/","title":{"rendered":"How to Install MongoDB 4.x on CentOS"},"content":{"rendered":"\r\n
MongoDB is a popular NoSQL database system that provides scalability, high performance, and availability. In this step-by-step guide, we\u2019ll walk through the installation process for MongoDB 4.x Community Edition on CentOS.<\/p>\r\n\r\n\r\n\r\n
Before you begin, ensure that you have the following prerequisites:<\/p>\r\n
sudo<\/code>)<\/li>\r\n <\/ul>\r\n
<\/p>\r\n\r\n\r\n\r\n
Installation Steps<\/h2>\r\n\r\n\r\n\r\n1. Configure the Package Management System (yum)<\/h3>\r\n
Create a file named \/etc\/yum.repos.d\/mongodb-org-4.4.repo<\/code> to set up the MongoDB repository for installation using yum<\/code>. You can use the following command to create the file:<\/p>\r\n sudo vi \/etc\/yum.repos.d\/mongodb-org-4.4.repo<\/blockquote>\r\n Add the following content to the file:<\/p>\r\n
[mongodb-org-4.4]
\r\nname=MongoDB Repository
\r\nbaseurl=https:\/\/repo.mongodb.org\/yum\/redhat\/$releasever\/mongodb-org\/4.4\/x86_64\/
\r\ngpgcheck=1
\r\nenabled=1
\r\ngpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-4.4.asc\r\n <\/blockquote>\r\n\r\n\r\n\r\n2. Install MongoDB Packages<\/h3>\r\n
Open a terminal and run the following command to install the latest stable version of MongoDB:<\/p>\r\n
sudo yum install -y mongodb-org<\/blockquote>\r\n Alternatively, if you want to install a specific release of MongoDB, specify each component package individually and append the version number to the package name. For example:<\/p>\r\n
sudo yum install -y mongodb-org-4.4.29 mongodb-org-server-4.4.29 mongodb-org-shell-4.4.29 mongodb-org-mongos-4.4.29 mongodb-org-tools-4.4.29<\/blockquote>\r\n\r\n\r\n\r\n3. Start MongoDB Service<\/h3>\r\n
After installation, start the MongoDB service using the following command:<\/p>\r\n
sudo systemctl start mongod<\/blockquote>\r\n\r\n\r\n\r\n4. Enable MongoDB to Launch on Boot<\/h3>\r\n
To ensure MongoDB starts automatically when your system boots up, enable it with:<\/p>\r\n
sudo systemctl enable mongod<\/blockquote>\r\n\r\n\r\n\r\n5. Access MongoDB Shell<\/h3>\r\n
To interact with MongoDB, open the MongoDB shell by entering:<\/p>\r\n
mongo<\/blockquote>\r\n\r\n\r\n\r\nConclusion<\/h2>\r\n
You\u2019ve successfully installed MongoDB on CentOS! Feel free to explore its features and start building your applications. Remember to check the official MongoDB documentation for any additional details or troubleshooting tips. Happy coding! \ud83d\ude80\ud83c\udf1f<\/p>\r\n\r\n\r\n\r\n
Congratulations! You have successfully installed MongoDB server on your system. For practice, you may use the MongoDB browser shell.<\/p>\r\n\r\n\r\n\r\n