Install and uninstall MongoDB using the Yum source on CentOS 7
1. Configure Yum Feed
1vim / 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
two。 Install MongoDB
Mongodb-org will contain mongodb-org-server, mongodb-org-mongos, mongodb-org-shell, mongodb-org-tools
1sudo yum install-y mongodb-org
3. Configure SELinux
1semanage port-a-t mongod_port_t-p tcp 27017
Or
1vi / etc/selinux/config
SELINUX=disabled
Restart
Or
1vi / etc/selinux/config
SELINXU=permissive
Restart
4. Check data and log file access permissions
The default data file is / var/lib/mongo, and the default log file is / var/log/mongodb. When the file directory is modified in the configuration file / etc/mongod.conf, be sure to grant mongod user access.
5. Modify bind_ip
The default bind_ip setting is 127.0.0.1, modify it as needed, and then restart the service.
6. Start the service
123systemctl start mongod systemctl enable mongod ss-tunpl | grep 27017
Uninstall MongoDB
This process will completely remove MongoDB, its configuration, and all databases.
1. Out of Service
1systemctl stop mongod
two。 Remove package
1sudo yum erase $(rpm-qa | grep mongodb-org)
3. Remove data and log files
12sudo rm-r / var/log/mongodb sudo rm-r / var/lib/mongo
Reference:
Https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/