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

推荐订阅源

Help Net Security
Help Net Security
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
C
Check Point Blog
M
MIT News - Artificial intelligence
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
U
Unit 42
D
Docker
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
H
Help Net Security
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
H
Heimdal Security Blog
S
Security @ Cisco Blogs
V
Visual Studio Blog
The Last Watchdog
The Last Watchdog
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
爱范儿
爱范儿
博客园 - 聂微东
S
Securelist
小众软件
小众软件
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
Apple Machine Learning Research
Apple Machine Learning Research

冰峰博客

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 协议,完整转载请注明