Centos 7.2 Installation and uninstallation of MongoDB database tutorial

  • 2020-11-03 22:38:34
  • OfStack

1. Introduction

As we all know, MongoDB is written by C++ language. It is an open source database system based on distributed file storage.

MongoDB is designed to provide scalable, high-performance data storage solutions for WEB applications.

MongoDB stores the data as a document. The data structure consists of key value pairs (ES13en-ES14en), the document is similar to the JSON object, and the field values can contain other documents, arrays, and arrays of documents. Adding more nodes guarantees server performance under high loads.

This article will give you a detailed introduction to the installation and uninstallation of MongoDB in Centos 7.2. Let's start with the detailed introduction.

2. Install

2.1 add source


vim /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

2.2 installation


yum install -y mongodb-org

2.3 Startup service


service mongod start

Results:


[root@localhost ~]# service mongod start
Redirecting to /bin/systemctl start mongod.service
[root@localhost ~]# ps -ef | grep mongod
mongod 24960 1 1 23:43 ? 00:00:00 /usr/bin/mongod -f /etc/mongod.conf
root 24989 24056 0 23:43 pts/0 00:00:00 grep --color=auto mongod

2.4 Boot from the machine


chkconfig mongod on

3. Introduction to the catalogue

Configuration file:


/etc/mongod.conf

Data directory:


/var/lib/mongo

Log directory:


/var/log/mongodb

If you need to change the data directory and log directory, simply change the storage.dbPath and systemLog.path in /etc/ mongod.conf.

4. Remove

4.1 Shut down service


service mongod stop

4.2 Delete the relevant packages


yum erase $(rpm -qa | grep mongodb-org)

4.3 Delete directories and files


yum install -y mongodb-org
0

5. Run into problems

1) Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted

Solution: Delete the file

2) Unable to lock file: /var/lib/mongo/mongod.lock

Solution: Empty the file contents

conclusion


Related articles: