Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Yum install MongoDB

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Brief introduction

MongoDB provides officially supported packages in its own repository. This repository contains the following packages:

(1) mongodb-org: one metapackage, the following four component packages will be installed automatically.

(2) mongodb-org-server: contains the mongod daemon, associated init script and configuration file (/ etc/mongod.conf). You can use the initialization script to start with the mongod configuration file. By default / etc/mongod.conf, the configuration file provided by the package has been set to 127.0.0.1 by bind_ip. Before initializing the replica set, modify this setting according to your environment needs.

(3) mongodb-org-mongos: contains mongos daemons.

(4) mongodb-org-shell: contains mongoshell.

(5) mongodb-org-tools: some extensions

1. System environment:

1. System version

CentOS Linux release 7.4.1708 (Core)

1. Recommended yum source [set source according to version]

Vim / etc/yum.repos.d/mongodb-org-4.0.repo

[mongodb-org-4.0]

Name = MongoDB Repository

Baseurl = https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/

Gpgcheck = 1

Enabled = 1

Gpgkey = https://www.mongodb.org/static/pgp/server-4.0.asc

The version of MongoDB is earlier than 4.0.

[mongodb-org-3.6]

Name = MongoDB Repository

Baseurl = https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/

Gpgcheck = 1

Enabled = 1

Gpgkey = https://www.mongodb.org/static/pgp/server-3.6.asc

Keep in mind that odd-numbered versions (e.g. 3.5) are development versions and are not suitable for production

2. Install MongoDB software package

Method 1: install the latest stable version of MongoDB

[root@edu-mycat-01 yum.repos.d] # yum install-y mongodb-org

Method 2: install a specific version of MongoDB, specify each component package separately and append the version number to the package name, as shown in the following example:

[root@edu-mycat-01 yum.repos.d] # yum install-y mongodb-org-3.7.3 mongodb-org-server-3.7.3 mongodb-org-shell-3.7.3 mongodb-org-mongos-3.7.3 mongodb-org-tools-3.7.3

You can specify any available version of MongoDB. However, yum, when a newer version is available, will upgrade the package. In order to prevent accidental upgrade, please nail the package. To fix the wrapper, add the following exclude directive to your / etc/yum.conf file:

Exclude = mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

3. SELinux settings (permissive mode is used here)

Permission is required if enabled: semanage port-a-t mongod_port_t-p tcp 27017

The MongoDB instance stores its data file / var/lib/mongo and its log file / var/log/mongodb by default and runs using the mongod user account. You can specify alternate log and data file directories / etc/mongod.conf in

4. Mongodb service

1) start

[root@edu-mycat-01 mongo] # systemctl start mongod

2) restart

[root@edu-mycat-01 mongo] # systemctl restart mongod

3) close

[root@edu-mycat-01 mongo] # systemctl stop mongod

4) View command

5. Use MongoDB

[root@edu-mycat-01 mongo] # mongo-- host 127.0.0.1 purl 27017

6. Uninstall MongoDB Community

1) stop mongod

2) Delete dependency packages

Yum remove $(rpm-qa | grep mongodb-org)

3) Delete files

# rm-r / var / log / mongodb # rm-r / var / lib / mongo

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report