To install MongoDB 4.0 (for other versions, see release note) on CentOS 7, create file
vi /etc/yum.repos.d/mongodb-org-4.0.repo
Add content
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Install MongoDB with
yum install -y mongodb-org
Enable MongoDB start on boot
systemctl enable mongod
Start Mongo DB with
systemctl start mongod
To see mongoDB version, run
[root@ns3084948 ~]# mongo --version
MongoDB shell version v4.0.10
git version: c389e7f69f637f7a1ac3cc9fae843b635f20b766
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64
[root@ns3084948 ~]#
To see if mongoDB running
[root@ns3084948 ~]# netstat -lntp | grep mongo
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 10349/mongod
[root@ns3084948 ~]#
Or use
[root@ns3084948 ~]# systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-06-04 06:08:01 BST; 18min ago
Docs: https://docs.mongodb.org/manual
Process: 10347 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
Process: 10344 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 10341 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 10338 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Main PID: 10349 (mongod)
Memory: 46.7M
CGroup: /system.slice/mongod.service
└─10349 /usr/bin/mongod -f /etc/mongod.conf
Jun 04 06:07:57 ns3084948.ip-145-239-4.eu systemd[1]: Starting MongoDB Database Server...
Jun 04 06:07:58 ns3084948.ip-145-239-4.eu mongod[10347]: 2019-06-04T06:07:58.013+0100 I CONTROL [main] WARNING: Cannot detect if NUMA interleaving is enabled. Failed to probe "/sys/devices...ssion denied
Jun 04 06:07:58 ns3084948.ip-145-239-4.eu mongod[10347]: about to fork child process, waiting until server is ready for connections.
Jun 04 06:07:58 ns3084948.ip-145-239-4.eu mongod[10347]: forked process: 10349
Jun 04 06:08:01 ns3084948.ip-145-239-4.eu mongod[10347]: child process started successfully, parent exiting
Jun 04 06:08:01 ns3084948.ip-145-239-4.eu systemd[1]: Started MongoDB Database Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ns3084948 ~]#