安装MongoDB

查看MongoDB版本可以执行如下命令

复制代码
mongod --version

如果是Ubuntu,则直接安装

复制代码
sudo apt-get install -y mongodb

如果是其他,比如Amazon Linux2。

查看Linux系统发行版类型

复制代码
grep ^NAME  /etc/*release

如果是 Amazon Linux 2,则创建一个repo文件 在这里

复制代码
/etc/yum.repos.d/mongodb-org-7.0.repo

其中代码如下

复制代码
[mongodb-org-7.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/7.0/aarch64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-7.0.asc

然后开始安装

复制代码
sudo yum install -y mongodb-org

查看使用哪一种 init 系统命令行

复制代码
ps --no-headers -o comm 1

Then select the appropriate tab below based on the result:

  • systemd - select the systemd (systemctl) tab below.

  • init - select the System V Init (service) tab below.

启动MongoDB

复制代码
sudo systemctl start mongod

如果报下面错,

复制代码
Failed to start mongod.service: Unit mongod.service not found.

则需要

复制代码
sudo systemctl daemon-reload

查看是否启动成功

复制代码
sudo systemctl status mongod

如果系统经过重启,可以

复制代码
sudo systemctl enable mongod

参见:Install MongoDB Community Edition on Amazon Linux --- MongoDB Manual

相关推荐
李兆龙的博客5 小时前
问津集 #26:Lakebase——Postgres 的版本化页面存储、数据库分支与计算弹性
数据库
倔强的石头_7 小时前
聊聊金仓KFS:一款把数据同步软件做扎实的产品
数据库
闲云野鹤在人间7 小时前
MySQL|从理论、安装、备份到主从复制、MHA高可用详解
linux·运维·数据库·mysql·云计算
禾小西7 小时前
Redis:从两大维度和三大主线建立知识体系
数据库·redis·缓存
禾小西8 小时前
Redis 数据结构:快速的 Redis 有哪些慢操作?
数据结构·数据库·redis
数据库小学妹8 小时前
数据共享交换平台选型:交换方式对比与避坑指南
数据库·信创·数据同步·数据交换平台·政务数据共享·数据共享交换平台·数据库底座
loong_XL10 小时前
决策模型做内容安全检测:从踩坑到上线
数据库·安全·jev·决策模型
这个DBA有点耶10 小时前
数据库双轨并行实战:全量并行策略、增量延迟控制、双向回切与一致性校验
数据库·架构·dba
adinnet202611 小时前
保单、赔付与渠道问数:保险经营数据如何实现按需查询
大数据·数据库·人工智能
云贝贝贝11 小时前
PostgreSQL 分区表:从设计到运维,大表不再卡
运维·数据库·postgresql