1.安装
vi /etc/yum.repos.d/mongodb-org-5.0.repo
# 内容如下
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
sudo yum install -y mongodb-org
或者离线安装
下载离线包
yum localinstall mongodb-org-server-5.0.11-1.el7.x86_64.rpm
2.配置
# 修改配置文件
vi /etc/mongod.conf
# 开启安全模式
...
security:
authorization: enabled
...
# 改变文件用户组
chown -R mongod:mongod /data/mongodb
# 非安全模式提示:Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
3.启动
# 启动
systemctl start mongod