How to install MongoDB on CentOS 7


We will install MongoDB 5.0 on CentOS 7

Step 1: install requirements

yum install python2 -y
yum install cyrus-sasl -y
yum install cyrus-sasl-gssapi -y
yum install cyrus-sasl-plain -y

Step 2:
Find RPM file here

mongodb-org-server-5.0.0:
mongodb-org-server-5.0.0-1.el7.x86_64.rpm

mongodb-database-tools-100
mongodb-database-tools-100.4.0.x86_64.rpm

mongodb-org-database-tools-extra-5.0.0
mongodb-org-database-tools-extra-5.0.0-1.el7.x86_64.rpm

mongodb-org-shell-5.0.0-1.el7.x86_64.rpm
mongodb-org-shell-5.0.0-1.el7.x86_64.rpm

Step 3:

rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.0-1.el7.x86_64.rpm
rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-database-tools-100.4.0.x86_64.rpm
rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-database-tools-extra-5.0.0-1.el7.x86_64.rpm
rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-shell-5.0.0-1.el7.x86_64.rpm

Result:

[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.0-1.el7.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.0-1.el7.x86_64.rpm
warning: /var/tmp/rpm-tmp.jdYtJs: Header V3 RSA/SHA1 Signature, key ID e2c63c11: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mongodb-org-server-5.0.0-1.el7   ################################# [100%]
Created symlink from /etc/systemd/system/multi-user.target.wants/mongod.service to /usr/lib/systemd/system/mongod.service.
[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-database-tools-100.4.0.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-database-tools-100.4.0.x86_64.rpm
warning: /var/tmp/rpm-tmp.njh2dz: Header V3 RSA/SHA1 Signature, key ID e2c63c11: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mongodb-database-tools-100.4.0-1 ################################# [100%]
[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-database-tools-extra-5.0.0-1.el7.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-database-tools-extra-5.0.0-1.el7.x86_64.rpm
warning: /var/tmp/rpm-tmp.awjKjk: Header V3 RSA/SHA1 Signature, key ID e2c63c11: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mongodb-org-database-tools-extra-################################# [100%]
[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-shell-5.0.0-1.el7.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/5.0/x86_64/RPMS/mongodb-org-shell-5.0.0-1.el7.x86_64.rpm
warning: /var/tmp/rpm-tmp.ttnMrU: Header V3 RSA/SHA1 Signature, key ID e2c63c11: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mongodb-org-shell-5.0.0-1.el7    ################################# [100%]

Step 4:

systemctl enable mongod
systemctl start mongod

By default, MongoDB runs using the mongod user account and uses the following default directories:

/var/lib/mongo (the data directory)
/var/log/mongodb (the log directory)

The configuration file /etc/mongod.conf

All files installed:

[root@tutorialspots ~]# rpm -ql mongodb-org-server
/etc/mongod.conf
/run/mongodb
/usr/bin/mongod
/usr/lib/systemd/system/mongod.service
/usr/share/doc/mongodb-org-server-5.0.0
/usr/share/doc/mongodb-org-server-5.0.0/LICENSE-Community.txt
/usr/share/doc/mongodb-org-server-5.0.0/MPL-2
/usr/share/doc/mongodb-org-server-5.0.0/README
/usr/share/doc/mongodb-org-server-5.0.0/THIRD-PARTY-NOTICES
/usr/share/man/man1/mongod.1.gz
/var/lib/mongo
/var/log/mongodb
[root@tutorialspots ~]# rpm -ql mongodb-org-database-tools-extra
/usr/bin/install_compass
[root@tutorialspots ~]# rpm -ql mongodb-database-tools
/usr/bin/bsondump
/usr/bin/mongodump
/usr/bin/mongoexport
/usr/bin/mongofiles
/usr/bin/mongoimport
/usr/bin/mongorestore
/usr/bin/mongostat
/usr/bin/mongotop
/usr/share/doc/mongodb-database-tools/LICENSE.md
/usr/share/doc/mongodb-database-tools/README.md
/usr/share/doc/mongodb-database-tools/THIRD-PARTY-NOTICES
[root@tutorialspots ~]# rpm -ql mongodb-org-shell
/usr/bin/mongo
/usr/share/man/man1/mongo.1.gz

Leave a Reply