How to install MongoDB on CentOS 8


We will install MongoDB 4.4 on CentOS 8

Step 1: install requirements

yum install python2 -y
yum install cyrus-sasl -y

Result:

...
[root@tutorialspots ~]# yum install cyrus-sasl -y
Last metadata expiration check: 0:31:25 ago on Sun 04 Oct 2020 02:22:52 PM UTC.
Dependencies resolved.
================================================================================
<%%KEEPWHITESPACE%%> Package            Architecture   Version                 Repository      Size
================================================================================
Installing:
<%%KEEPWHITESPACE%%> cyrus-sasl         x86_64         2.1.27-1.el8            BaseOS          96 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 96 k
Installed size: 160 k
Downloading Packages:
cyrus-sasl-2.1.27-1.el8.x86_64.rpm              6.0 MB/s |  96 kB     00:00
--------------------------------------------------------------------------------
Total                                           202 kB/s |  96 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
<%%KEEPWHITESPACE%%>  Preparing        :                                                        1/1
<%%KEEPWHITESPACE%%>  Running scriptlet: cyrus-sasl-2.1.27-1.el8.x86_64                         1/1
<%%KEEPWHITESPACE%%>  Installing       : cyrus-sasl-2.1.27-1.el8.x86_64                         1/1
<%%KEEPWHITESPACE%%>  Running scriptlet: cyrus-sasl-2.1.27-1.el8.x86_64                         1/1
<%%KEEPWHITESPACE%%>  Verifying        : cyrus-sasl-2.1.27-1.el8.x86_64                         1/1
Installed products updated.

Installed:
<%%KEEPWHITESPACE%%>  cyrus-sasl-2.1.27-1.el8.x86_64

Complete!

Step 2:
Find RPM file here

mongodb-org-server-4.4.1:
mongodb-org-server-4.4.1-1.el8.x86_64.rpm

mongodb-database-tools:
mongodb-database-tools-100.2.0.x86_64.rpm

mongodb-org-database-tools-extra:
mongodb-org-database-tools-extra-4.4.1-1.el8.x86_64.rpm

mongodb-org-shell-4.4.1
mongodb-org-shell-4.4.1-1.el8.x86_64.rpm

Step 3:

rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.1-1.el8.x86_64.rpm
rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-database-tools-100.2.0.x86_64.rpm
rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-database-tools-extra-4.4.1-1.el8.x86_64.rpm
rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-shell-4.4.1-1.el8.x86_64.rpm

Result:

[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.1-1.el8.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.1-1.el8.x86_64.rpm
warning: /var/tmp/rpm-tmp.4AgVQv: Header V3 RSA/SHA1 Signature, key ID 90cfb1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
<%%KEEPWHITESPACE%%>   1:mongodb-org-server-4.4.1-1.el8   ################################# [100%]
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /usr/lib/systemd/system/mongod.service.

[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-database-tools-100.2.0.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-database-tools-100.2.0.x86_64.rpm
warning: /var/tmp/rpm-tmp.VgN3nk: Header V3 RSA/SHA1 Signature, key ID 90cfb1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
<%%KEEPWHITESPACE%%>   1:mongodb-database-tools-100.2.0-1 ################################# [100%]

[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-database-tools-extra-4.4.1-1.el8.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-database-tools-extra-4.4.1-1.el8.x86_64.rpm
warning: /var/tmp/rpm-tmp.EHyGjG: Header V3 RSA/SHA1 Signature, key ID 90cfb1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
<%%KEEPWHITESPACE%%>   1:mongodb-org-database-tools-extra-################################# [100%]

[root@tutorialspots ~]# rpm -ivh https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-shell-4.4.1-1.el8.x86_64.rpm
Retrieving https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.4/x86_64/RPMS/mongodb-org-shell-4.4.1-1.el8.x86_64.rpm
warning: /var/tmp/rpm-tmp.KPbNRB: Header V3 RSA/SHA1 Signature, key ID 90cfb1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mongodb-org-shell-4.4.1-1.el8    ################################# [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 ~]# dnf repoquery --installed -l mongodb-org-database-tools-extra
/usr/bin/install_compass
/usr/share/man/man1/mongoldap.1
[root@tutorialspots ~]# dnf repoquery --installed -l 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/lib/.build-id
/usr/lib/.build-id/15
/usr/lib/.build-id/15/319fa38b5ddd8e0efb6cff67f72ca2eef6c198
/usr/lib/.build-id/41
/usr/lib/.build-id/41/8df3de2979de37b93f2ce0740e07324f276846
/usr/lib/.build-id/64
/usr/lib/.build-id/64/16061bd13650f6794d701bf7ff1202dfc3bc24
/usr/lib/.build-id/72
/usr/lib/.build-id/72/bc59af6ff96eeca310b39d96c9f8fafbd29f14
/usr/lib/.build-id/8a
/usr/lib/.build-id/8a/7adaacdf7c6351c3ab12b33d1445acdd3eee6d
/usr/lib/.build-id/8b
/usr/lib/.build-id/8b/4116d33a881637ac420cce641cc7dbfc9fc1f4
/usr/lib/.build-id/ae
/usr/lib/.build-id/ae/8412284e5b7b52d1b634aceb04100c3ba6071c
/usr/lib/.build-id/c2
/usr/lib/.build-id/c2/03023769729669c68561777a9bc89bda09712b
/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 ~]# dnf repoquery --installed -l mongodb-org-server
/etc/mongod.conf
/lib/systemd/system/mongod.service
/usr/bin/mongod
/usr/lib/.build-id
/usr/lib/.build-id/b3
/usr/lib/.build-id/b3/93c2f3de718c68d314f2ae0ebeadc575d68665
/usr/share/doc/mongodb-org-server-4.4.1
/usr/share/doc/mongodb-org-server-4.4.1/LICENSE-Community.txt
/usr/share/doc/mongodb-org-server-4.4.1/MPL-2
/usr/share/doc/mongodb-org-server-4.4.1/README
/usr/share/doc/mongodb-org-server-4.4.1/THIRD-PARTY-NOTICES
/usr/share/man/man1/mongod.1
/var/lib/mongo
/var/log/mongodb
/var/log/mongodb/mongod.log
/var/run/mongodb
[root@tutorialspots ~]# dnf repoquery --installed -l mongodb-org-shell
/usr/bin/mongo
/usr/lib/.build-id
/usr/lib/.build-id/1b
/usr/lib/.build-id/1b/41c0d9ff1d665ded8c01b04234ef8c21a3d6ba
/usr/share/man/man1/mongo.1

Leave a Reply