Centos7 yum installation mongodb implementation steps detail

  • 2021-01-19 22:31:26
  • OfStack

Introduction to the

MongoDB is an NoSQL database based on distributed file storage Written by C++ language, stable operation, high performance Designed to provide scalable high-performance data storage solutions for WEB applications Check the official website

MongoDB characteristics

Schema-free: Documents with different structures can be stored in the same database Collection-oriented storage: A format suitable for storing JSON style files Full indexing support: Indexable on any attribute Replication and high availability: Support data replication between servers, master-slave mode and replication between servers. The main purpose of replication is to provide redundancy and automatic failover Automatic sharding: Support cloud-level scalability: Automatic sharding supports horizontal database clustering with the ability to dynamically add additional machines Rich query: support rich query expression, query instructions use JSON form of tags, can easily query the embedded objects and arrays in the document Fast in-place update: The query optimizer analyzes the query expression and produces an efficient query plan Efficient traditional storage: Supported binary data and large objects (such as photos or images)

Packages package

The MongoDB official source contains the following dependency packages:

mongodb-org: MongoDB Metadata Package, which automatically installs the following 4 components:

1.mongodb-org-server: Contains the MongoDB daemon and associated configuration and initialization scripts. 2. mongodb-org-mongos: daemon containing mongos 3.mongodb-org-shell: Includes mongo shell. 4.mongodb-org-tools: Tools including MongoDB: mongoimport, bsondump, mongodump, mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop.

Installation steps

1. Configure yum source for MongoDB

vim /etc/yum.repos.d/mongodb-org-3.4.repo
# Add the following: 
name=MongoDB Repository 

# I can change it here  gpgcheck=0,  save gpg validation [root@localhost ~]# yum makecache

2. Install MongoDB

Installation command:

yum -y install mongodb-org

Upon completion of installation


mongodb-org.x86_64 0:3.4.14-1.el7

Installed as a dependency:


mongodb-org-mongos.x86_64 0:3.4.14-1.el7 mongodb-org-server.x86_64 0:3.4.14-1.el7
mongodb-org-shell.x86_64 0:3.4.14-1.el7 mongodb-org-tools.x86_64 0:3.4.14-1.el7



[root@adminset yum.repos.d]#

View the mongo installation location:

whereis mongod

To view the modified configuration file:

vim /etc/mongod.conf

3. Start MongoDB

Start the mongodb:

systemctl start mongod.service

Stop mongodb:

systemctl stop mongod.service

Status of mongodb found:

systemctl status mongod.service

4. To access the external network, you need to close the firewall:

Close the firewall:


systemctl stop firewalld.service # Stop firewall
systemctl disable firewalld.service # Disallow firewall boot startup


5. Start Mongo shell



View the database:

show dbs

6. Set mongodb remote access:

Edit mongod.conf comment bindIp and restart mongodb.

vim /etc/mongod.conf

Restart mongodb for the changes to take effect:

mongodb-org.x86_64 0:3.4.14-1.el70

Related articles: