[root@DBAMAXWELL home]# sudo tee /etc/yum.repos.d/mongodb-org-4.repo<<EOF
> [mongodb-org-4]
> name=MongoDB Repository
> baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.4/x86_64/
> gpgcheck=1
> enabled=1
> gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
> EOF
[mongodb-org-4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
[root@DBAMAXWELL home]# sudo yum install mongodb-org
MongoDB Repository 21 kB/s | 37 kB 00:01
Dependencies resolved.
==================================================================================================================================================
Package Architecture Version Repository Size
==================================================================================================================================================
Installing:
mongodb-org x86_64 4.4.13-1.el8 mongodb-org-4 11 k
Installing dependencies:
cyrus-sasl x86_64 2.1.27-5.el8 baseos 96 k
mongodb-database-tools x86_64 100.5.2-1 mongodb-org-4 47 M
mongodb-org-database-tools-extra x86_64 4.4.13-1.el8 mongodb-org-4 23 k
mongodb-org-mongos x86_64 4.4.13-1.el8 mongodb-org-4 17 M
mongodb-org-server x86_64 4.4.13-1.el8 mongodb-org-4 22 M
mongodb-org-shell x86_64 4.4.13-1.el8 mongodb-org-4 14 M
mongodb-org-tools x86_64 4.4.13-1.el8 mongodb-org-4 11 k
Transaction Summary
==================================================================================================================================================
Install 8 Packages
Total download size: 100 M
Installed size: 318 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): mongodb-org-4.4.13-1.el8.x86_64.rpm 34 kB/s | 11 kB 00:00
(2/8): mongodb-org-database-tools-extra-4.4.13-1.el8.x86_64.rpm 101 kB/s | 23 kB 00:00
(3/8): cyrus-sasl-2.1.27-5.el8.x86_64.rpm 75 kB/s | 96 kB 00:01
(4/8): mongodb-org-mongos-4.4.13-1.el8.x86_64.rpm 5.1 MB/s | 17 MB 00:03
(5/8): mongodb-org-shell-4.4.13-1.el8.x86_64.rpm 4.0 MB/s | 14 MB 00:03
(6/8): mongodb-org-tools-4.4.13-1.el8.x86_64.rpm 49 kB/s | 11 kB 00:00
(7/8): mongodb-org-server-4.4.13-1.el8.x86_64.rpm 3.3 MB/s | 22 MB 00:06
(8/8): mongodb-database-tools-100.5.2.x86_64.rpm 5.3 MB/s | 47 MB 00:08
--------------------------------------------------------------------------------------------------------------------------------------------------
Total 11 MB/s | 100 MB 00:09
MongoDB Repository 1.6 kB/s | 1.6 kB 00:01
Importing GPG key 0x90CFB1F5:
Userid : "MongoDB 4.4 Release Signing Key <packaging@mongodb.com>"
Fingerprint: 2069 1EEC 3521 6C63 CAF6 6CE1 6564 08E3 90CF B1F5
From : https://www.mongodb.org/static/pgp/server-4.4.asc
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : mongodb-org-shell-4.4.13-1.el8.x86_64 1/8
Running scriptlet: mongodb-org-server-4.4.13-1.el8.x86_64 2/8
Installing : mongodb-org-server-4.4.13-1.el8.x86_64 2/8
Running scriptlet: mongodb-org-server-4.4.13-1.el8.x86_64 2/8
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /usr/lib/systemd/system/mongod.service.
Installing : mongodb-org-mongos-4.4.13-1.el8.x86_64 3/8
Installing : mongodb-org-database-tools-extra-4.4.13-1.el8.x86_64 4/8
Running scriptlet: cyrus-sasl-2.1.27-5.el8.x86_64 5/8
Installing : cyrus-sasl-2.1.27-5.el8.x86_64 5/8
Running scriptlet: cyrus-sasl-2.1.27-5.el8.x86_64 5/8
Running scriptlet: mongodb-database-tools-100.5.2-1.x86_64 6/8
Installing : mongodb-database-tools-100.5.2-1.x86_64 6/8
Running scriptlet: mongodb-database-tools-100.5.2-1.x86_64 6/8
Installing : mongodb-org-tools-4.4.13-1.el8.x86_64 7/8
Installing : mongodb-org-4.4.13-1.el8.x86_64 8/8
Running scriptlet: mongodb-org-4.4.13-1.el8.x86_64 8/8
Verifying : cyrus-sasl-2.1.27-5.el8.x86_64 1/8
Verifying : mongodb-database-tools-100.5.2-1.x86_64 2/8
Verifying : mongodb-org-4.4.13-1.el8.x86_64 3/8
Verifying : mongodb-org-database-tools-extra-4.4.13-1.el8.x86_64 4/8
Verifying : mongodb-org-mongos-4.4.13-1.el8.x86_64 5/8
Verifying : mongodb-org-server-4.4.13-1.el8.x86_64 6/8
Verifying : mongodb-org-shell-4.4.13-1.el8.x86_64 7/8
Verifying : mongodb-org-tools-4.4.13-1.el8.x86_64 8/8
Installed:
cyrus-sasl-2.1.27-5.el8.x86_64 mongodb-database-tools-100.5.2-1.x86_64 mongodb-org-4.4.13-1.el8.x86_64
mongodb-org-database-tools-extra-4.4.13-1.el8.x86_64 mongodb-org-mongos-4.4.13-1.el8.x86_64 mongodb-org-server-4.4.13-1.el8.x86_64
mongodb-org-shell-4.4.13-1.el8.x86_64 mongodb-org-tools-4.4.13-1.el8.x86_64
Complete!
[root@DBAMAXWELL home]#
You can verify installation of above packages, e.g.
[root@DBAMAXWELL home]# rpm -qi mongodb-org-server
Name : mongodb-org-server
Version : 4.4.13
Release : 1.el8
Architecture: x86_64
Install Date: Wed 23 Mar 2022 11:21:11 PM CST
Group : Applications/Databases
Size : 83495609
License : SSPL
Signature : RSA/SHA1, Mon 07 Mar 2022 10:50:33 PM CST, Key ID 656408e390cfb1f5
Source RPM : mongodb-org-4.4.13-1.el8.src.rpm
Build Date : Thu 03 Mar 2022 12:17:45 AM CST
Build Host : ip-10-122-92-37.ec2.internal
Relocations : /usr /var /etc
URL : http://www.mongodb.org
Summary : MongoDB database server
Description :
MongoDB is built for scalability, performance and high availability, scaling from single server deployments to large, complex multi-site architectures. By leveraging in-memory computing, MongoDB provides high performance for both reads and writes. MongoDB’s native replication and automated failover enable enterprise-grade reliability and operational flexibility.
MongoDB is an open-source database used by companies of all sizes, across all industries and for a wide variety of applications. It is an agile database that allows schemas to change quickly as applications evolve, while still providing the functionality developers expect from traditional databases, such as secondary indexes, a full query language and strict consistency.
MongoDB has a rich client ecosystem including hadoop integration, officially supported drivers for 10 programming languages and environments, as well as 40 drivers supported by the user community.
MongoDB features:
* JSON Data Model with Dynamic Schemas
* Auto-Sharding for Horizontal Scalability
* Built-In Replication for High Availability
* Rich Secondary Indexes, including geospatial
* TTL indexes
* Text Search
* Aggregation Framework & Native MapReduce
This package contains the MongoDB server software, default configuration files, and systemd service files.
[root@DBAMAXWELL home]#
Configure MongoDB on Centos8
When the package has been installed,you can start customizing and configuring MongDB before starting the service.
Label MongoDB port
If you have SELinux in enforcing mode,you may need to label port 27017
[root@DBAMAXWELL home]#
[root@DBAMAXWELL home]# sudo semanage port -a -t mongod_port_t -p tcp 27017
[root@DBAMAXWELL home]#
Allow mongo port on the firewall
If you have firewalld running on your server and would like MongoDB service to be accessible over the network, open it on the firewall:
[root@DBAMAXWELL home]#
[root@DBAMAXWELL home]# sudo firewall-cmd --add-port=27017/tcp --permanent
FirewallD is not running
[root@DBAMAXWELL home]# sudo firewall-cmd --reload
FirewallD is not running
[root@DBAMAXWELL home]#
[root@DBAMAXWELL home]# sudo firewall-cmd --permanent --add-rich-rule "rule family="ipv4" \
> source address="10.10.20.0/24" port protocol="tcp" port="27017" accept"
FirewallD is not running
[root@DBAMAXWELL home]#
[root@DBAMAXWELL home]# sudo systemctl enable --now mongod
[root@DBAMAXWELL home]# systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2022-03-23 23:33:56 CST; 21s ago
Docs: https://docs.mongodb.org/manual
Process: 359826 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
Process: 359824 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 359821 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 359820 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Main PID: 359828 (mongod)
Memory: 124.4M
CGroup: /system.slice/mongod.service
└─359828 /usr/bin/mongod -f /etc/mongod.conf
Mar 23 23:33:55 DBAMAXWELL systemd[1]: Starting MongoDB Database Server...
Mar 23 23:33:55 DBAMAXWELL mongod[359826]: about to fork child process, waiting until server is ready for connections.
Mar 23 23:33:55 DBAMAXWELL mongod[359828]: forked process: 359828
Mar 23 23:33:56 DBAMAXWELL mongod[359826]: child process started successfully, parent exiting
Mar 23 23:33:56 DBAMAXWELL systemd[1]: Started MongoDB Database Server.
[root@DBAMAXWELL home]#