安装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

相关推荐
bksczm16 小时前
Redis Cluster 分片集群详解:槽路由、故障判定与扩缩容
数据库·redis·分布式
黑十17 小时前
FDE 怎么快速搭一个可演示页面?最小前端方案
java·大数据·前端·数据库·人工智能
Databend18 小时前
OpenRaft 自定义 Membership,按部署拓扑选择 Quorum
大数据·数据库·数据分析
Databend18 小时前
用 SQL 排查支付故障,OpenTelemetry 接入 Databend Cloud 实战
大数据·数据库·sql
kyle~18 小时前
SQLite -- 低成本持久化能力
数据库·sqlite
上海潭龙东海科技有限公司19 小时前
智慧堆场动态模型三维实时孪生重构智能管控
大数据·网络·数据库·算法·重构
老纪的技术唠嗑局19 小时前
OceanBase AI数据大会,我会这么逛
数据库
星恒随风19 小时前
MySQL 从零入门(九):事务管理详解——ACID、COMMIT、ROLLBACK、SAVEPOINT 与四种隔离级别
linux·服务器·数据库·笔记·mysql
草莓熊Lotso20 小时前
【C++ 基于微服务的即时通讯系统】ElasticSearch 用户数据管理实现
linux·数据库·c++·elasticsearch·微服务·架构