How to install mongodb 4.2 using yum on centos8

How to install mongodb 4.2 using yum on centos8

1. Make a repo file

Refer to the official installation documentation of mongodb and use the following script to create a Yum repository to install mongodb4.2. However, the installation process prompts "Failed to synchronize cache for repo 'mongodb-org-4.2'"

[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

The reason is that the official centos8 installation package has not yet been provided. Since the $releasever variable is 8, try to set the address to 7 to see if you can install a version based on centos7.

OK, use vim to create a repo file

sudo vim /etc/yum.repos.d/mongodb-org-4.2.repo

Enter the following configuration into the repo file, save it, and exit vim

[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

2. Install using the yum command

sudo yum install -y mongodb-org

The installation process once failed to download because the network was too slow. Just execute it again. After a while, it prompts that the installation is successful and the process goes smoothly.

3. Start mongodb

After installing and starting the service, you can use

The start, stop, and restart commands are as follows:

sudo service mongod start
sudo service mongod stop
sudo service mongod restart

4. Open remote connection to mongodb

The configuration file of mongodb is /etc/mongod.conf

If you want to open remote access, you need to modify the bindIp value of the file to: 0.0.0.0, otherwise you will not be able to connect through other computers.

sudo vim /etc/mongod.conf

After the file is modified, restart is required to make the configuration take effect.

sudo service mongod restart

If you still cannot connect remotely, open port 27017 in the firewall (this port is the default port of mongodb, and the port of mongodb can be modified through the configuration file)

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

Refer to the official installation instructions:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/#run-mongodb-community-edition

Summarize

The above is the method of installing mongodb 4.2 on centos8 using yum introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Solution to Mongodb not starting automatically after booting under Centos 7
  • Detailed installation of Mongodb in CentOS (online and offline)
  • Installation process of MongoDB database under CentOS7

<<:  WeChat Mini Program uses simultaneous interpretation to implement speech recognition

>>:  Detailed tutorial on compiling and installing MySQL 5.7.24 on CentOS7

Recommend

How to install and modify the initial password of mysql5.7.18

For Centos installation of MySQL, please refer to...

js to implement web calculator

How to make a simple web calculator using HTML, C...

Teach you how to implement the observer mode in Javascript

Table of contents What is the Observer Pattern? S...

Experience in solving tomcat memory overflow problem

Some time ago, I submitted a product version to t...

Detailed installation and configuration of MySql on Mac

1. Download and install Download the community ed...

A tutorial on how to install, use, and automatically compile TypeScript

1. Introduction to TypeScript The previous articl...

Getting Started with Nginx Reverse Proxy

Table of contents Overview The role of reverse pr...

Logrotate implements Catalina.out log rotation every two hours

1. Introduction to Logrotate tool Logrotate is a ...

How to set the position of the block element in the middle of the window

How to set the position of the block element in t...

Vue implements Tab tab switching

This article example shares the specific code of ...

How does JS understand data URLs?

Table of contents Overview Getting started with d...

How to implement the webpage anti-copying function (with cracking method)

By right-clicking the source file, the following c...

Awk command line or script that helps you sort text files (recommended)

Awk is a powerful tool that can perform some task...