Centos7下yum安装mongodb方法

2026-03-18 11:34:03

1、添加mongodb的yum源

cat >> /etc/yum.repos.d/mongodb-3.4.repo << 'EOF'

[mongodb-org-3.4]

name=MongoDB 3.4 Repository

baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/

gpgcheck=0

enabled=1

EOF

这里可以修改 gpgcheck=0, 省去gpg验证

Centos7下yum安装mongodb方法

2、会在/etc/yum.repos.d/中生成mongodb-3.4.repo文件

Centos7下yum安装mongodb方法

3、清空当前yum缓存和生成新的缓存

yum clean all

yum makecache

生成新的缓存可能等待的时间有点长

Centos7下yum安装mongodb方法

4、使用yum install mongodb-org命令进行安装

Centos7下yum安装mongodb方法

5、输入y并回车继续安装

Centos7下yum安装mongodb方法

6、关闭selinux

setenforce 0

Centos7下yum安装mongodb方法

7、关闭firewall

systemctl stop firewalld.service 

systemctl disable firewalld.service 

Centos7下yum安装mongodb方法

8、启动mongod

systemctl start mongod.service

Centos7下yum安装mongodb方法

猜你喜欢