How to install MongoDB on CentOS
Published: 05 March 2017
Filed Under: CentOS
MongoDB is an document-based NoSQL database. It provides high performance, high availability, and scaling. Data is stored as a document record made up of JSON objects.
Add the MongoDB repo
Create a new file called /etc/yum.repos.d/mongodb-org-4.2.repo and add the following text to it.
[mongodb-org-4.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
Run the following commands to install MongoDB and add an exception to SELinux to allow it to run with its default configuration.
sudo yum update sudo yum install mongodb-org sudo semanage port -a -t mongod_port_t -p tcp 27017
Start MongoDB and set it to automatically start when the system boots.
sudo systemctl start mongod sudo systemctl enable mongod