Installing mongodb on CentOS 7 (1)


Installing mongodb on CentOS

This article only records the process of installing mongodb on CentOS. Because Baidu had some tutorials before, the results were not ideal, so I decided to write it myself. The versions used in this tutorial areCentOS7andMongodb-3.6

Installation steps

Configure mongodb source on yum

Run command

vim /etc/yum.repos.d/mongodb-org-3.6.repo

After adding the following content, clickescThen enter:wq!Click enter to exit editing

name=MongoDB Repository

Then enteryum install -y mongodb-orgAnd wait for the installation to complete

Configuring SELinux

SELinux is a security subsystem of Linux system. This subsystem will control the resources that a process can call, so as to ensure the security of the system. Therefore, SELinux may have some impact on the operation of mongodb. There are three ways to solve this problem

1. If SELinux is in the enforcing mode, enable the default port 27017 used in mongodb deployment

semanage port -a -t mongod_port_t -p tcp 27017

2. Turn SELinux off

vim /etc/selinux/configThen change it to SELinux = disabled and save and exit

3. Set SELinux to permissive state. The operation is the same as 2.

Related documents

By default, mongodb stores data files in /var/lib/mongoUnder file, store the log file in/var/log/mongodbFile. Can be in/etc/mongod.confThese two paths are configured in the file.
If you switch users, you must give the user permission to these folders.

Basic instruction

Check whether mongodb is installed on the system:rpm -qa|grep mongodb

Installing mongodb on CentOS 7 (1)

View the installation path of the system: rpm -ql mongodb-org-server-3.6.0-0.1.rc0.el7.x86_64

Installing mongodb on CentOS 7 (1)

Open service:sudo service mongod startorsudo systemctl start mongod.service

View service on:sudo chkconfig mongod onor tail /var/log/mongodb/mongod.log
Installing mongodb on CentOS 7 (1)

Shut down service:sudo service mongod stoporsudo systemctl stop mongod.service

Restart service:sudo service mongod restartorsystemctl restart mongod.service

To delete mongodb:sudo yum erase $(rpm -qa | grep mongodb-org)
Delete data directory:sudo rm -r /var/log/mongodb; sudo rm -r /var/lib/mongo

reference resources

Mongodb official website installation tutorial
Remote connection with mongodb

Installing mongodb on CentOS 7 (1)
For more development techniques, interview tutorials and Internet Co push, please welcome my WeChat official account. Benefits will be paid from time to time~