vim /etc/yum.repos.d/mongodb-org-4.0.repo
复制以下内容到打开的文件中
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
sudo yum install -y mongodb-org
systemctl restart mongod.service
systemctl status mongod.service
netstat -ntlp #查看端口
mongo --host 127.0.0.1:27017
远程访问则设置
vim /etc/mongod.conf
将127.0.0.1改成 0.0.0.0