Saturday, January 18, 2020

Install MongoDB database on Centos 7


MongoDB is a noSQL database and is available on Centos Linux 7. Ensure that SElinux is only on permissive.

For cases SElinux is enforcing, additional steps need to be taken which is outside of this installation note.

Step 1: Configure the repository

Create the file /etc/yum.repos.d/mongodb-org.repo

[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

Step 2: Install and start

sudo yum install -y mongodb-org
sudo systemctl start mongod

If all is running good, then allow it to start at boot time.

sudo systemctl enable mongod

Step 3: Verify


mongo
db.version()
exit

Further configuration can be done with the file /etc/mongod.conf

Allow database through the firewall

sudo firewall-cmd --zone=public --add-port=27017/tcp --permanent
sudo firewall-cmd --reload

Those with Selinux in mode Enforcing, allow the default mongodb port.

sudo semanage port -a -t mongod_port_t -p tcp 27017

No comments:

Blog Archive