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

js implements random roll call

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

CentOS 6.5 installation mysql5.7 tutorial

1. New Features MySQL 5.7 is an exciting mileston...

Innodb system table space maintenance method

Environmental Description: There is a running MyS...

How to pop up a temporary QQ dialog box to chat online without adding friends

In fact, this is very simple. We add an a tag to ...

Vue + element dynamic multiple headers and dynamic slots

Table of contents 1. Demand 2. Effect 3. All code...

A brief discussion on the solution to excessive data in ElementUI el-select

Table of contents 1. Scenario Description 2. Solu...

js to achieve simple product screening function

This article example shares the specific code of ...

How to view the IP address of Linux in VMware virtual machine

1. First, double-click the vmware icon on the com...

How to install FastDFS in Docker

Pull the image docker pull season/fastdfs:1.2 Sta...

Font Treasure House 50 exquisite free English font resources Part 1

Designers have their own font library, which allo...

How to install lua-nginx-module module in Nginx

ngx_lua_module is an nginx http module that embed...

Vue Getting Started with Weather Forecast

This article example shares the specific code of ...