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

Solution to changing the data storage location of the database in MySQL 5.7

As the data stored in the MySQL database graduall...

Docker enables multiple port mapping commands

as follows: docker run -d -p 5000:23 -p 5001:22 -...

A brief discussion on the difference between src and href in HTML

Simply put, src means "I want to load this r...

MySQL index knowledge summary

The establishment of MySQL index is very importan...

Explain TypeScript mapped types and better literal type inference

Table of contents Overview Using mapped types to ...

Sample code for generating QR code using js

Some time ago, the project needed to develop the ...

Detailed explanation of CSS margin collapsing

Previous This is a classic old question. Since a ...

js to realize a simple puzzle game

This article shares the specific code of js to im...

Solution to Vue's inability to watch array changes

Table of contents 1. Vue listener array 2. Situat...

Use CSS to draw a file upload pattern

As shown below, if it were you, how would you ach...