惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
月光博客
月光博客
美团技术团队
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
爱范儿
爱范儿
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
I
InfoQ
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
F
Fortinet All Blogs

冰峰博客

在 IBM PowerVM 环境中安装 AOSC OS,并实现 HMC RMC 与 DLPAR JumpServer 资产代填配置 Windows 管理员获取所有权 ESXI 不识别 ISCSI 挂载盘解决方案 Mellanox ConnectX-4 Lx (MCX4421A-ACQ_Ax) 固件升级 VPS 通过OpenVPN访问家中存储服务 Proxmox Virtual Environment(PVE)使用 LXC 容器安装 AdGuard Home 博科 SAN 交换机 Zone 配置 VMware vSphere 小版本更新简要步骤 CentOS7 安装 Docker Hello Halo
CentOS7 安装 MongoDB
标签 · 2024-05-21 · via 冰峰博客

本文最后更新于 2023-10-25,文章内容可能已经过时。

注意:本文全程使用 root 账号,如果不是 root 账号,需要在命令前加 sudo

第一部分:配置 Yum 源

vim /etc/yum.repos.d/mongodb-org-6.0.repo

[mongodb-org-6.0]  
name=MongoDB Repository  
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/  
gpgcheck=0  
enabled=1  
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

第二部分:关闭防火墙以及禁用 SELinux

# 关闭防火墙
systemctl stop firewalld # 停止防火墙
systemctl disable firewalld # 禁用防火墙

# 禁用SELinux
sestatus # 查看 SELinux 状态

# 输出示例(已禁用)
    SELinux status:                 enabled
    SELinuxfs mount:                /sys/fs/selinux
    SELinux root directory:         /etc/selinux
    Loaded policy name:             targeted
    Current mode:                   enforcing
    Mode from config file:          enforcing
    Policy MLS status:              enabled
    Policy deny_unknown status:     allowed
    Max kernel policy version:      31

setenforce 0 # 临时将 SELinux 模式从目标更改为允许
vim /etc/selinux/config # 编辑 SELinux 配置文件

# 将 SELINUX=enforcing 改为 SELINUX=disabled (如下文所示)
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    SELINUX=disabled
    # SELINUXTYPE= can take one of these two values:
    #       targeted - Targeted processes are protected,
    #       mls - Multi Level Security protection.
    SELINUXTYPE=targeted

reboot # 保存并重启系统

# 使用 sestatus 命令验证更改
sestatus
# 示例输出
    SELinux status:                 disabled
# 安装 MongoDB
yum install mongodb-org -y

# 卸载 MongoDB
yum remove mongodb*

# 启动 MongoDB
systemctl start mongod

# 设置开机自启
systemctl enable mongod

# 查看运行状态( active (running) 表示正常运行)
systemctl status mongod

第四部分:验证是否安装成功

mongo --quiet "mongodb://127.0.0.1:27017" # 连接到数据库

# 出现以下子项表示安装成功
    $ mongo --quiet "mongodb://127.0.0.1:27017"
    Welcome to the MongoDB shell.
    > 

本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明