1. Configure the Yum source for MongoDB
To create a Yum source file:
Vim/etc/yum.repos.d/mongodb-org-3.6.repo
Add the following content:
[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
2. Installing MongoDB
installation command:
Yum-y Install mongodb-org
After the installation is complete, check the MONGO installation location Whereis Mongod
3. Start MongoDB
Start Mongodb:systemctl start Mongod.service
Stop Mongodb:systemctl Stop Mongod.service
4. External network access requires the firewall to be turned off:
CentOS 7.0 defaults to using firewall as the firewall, where the iptables firewall is changed.
Close firewall:
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动
5. Set Boot up
Systemctl Enable Mongod.service
6. Set up MongoDB remote access:
Edit mongod.conf Comment Bindip and restart MongoDB.
Vim/etc/mongod.conf
Centos7 Installing MongoDB 3.6