对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

使用以下程序在 Windows 上安装 MongoDB Enterprise: msiexec.exe

重要

MongoDB 8.3 是最新的次要发布。从MongoDB 8.2 开始,针对特定使用案例的本地部署部署(社区和 EA)可使用次要版本。 有关更多信息,请参阅MongoDB版本控制。

要安装支持本地部署使用的最新MongoDB版本,请参阅安装说明。

使用本教程安装MongoDB 8.3在命令行中使用 msiexec.exe 以无人值守的方式在Windows上运行 Enterprise 版。这对于使用自动化部署MongoDB 的系统管理员非常有用。

MongoDB Enterprise Edition可在部分平台上使用,并包含对安全和监控相关功能的支持。

本教程将安装 MongoDB 8.3 企业版。要安装其他版本的 MongoDB Enterprise,请使用此页面左上角的版本下拉菜单选择该版本的文档。

本教程使用命令行工具 msiexec.exe 在Windows上安装MongoDB 。您还可以使用以下方法在Windows上安装MongoDB :

The MongoDB Shell (mongosh) is not installed with MongoDB Server. You need to follow the mongosh installation instructions to download and install mongosh separately.

MongoDB 8.3 企业版支持以下采用 x86_64 架构的 64 位 Windows 版本:

  • Windows Server 2022

  • Windows 11

MongoDB 仅支持这些平台的 64 位版本。

有关更多信息,请参阅平台支持。

注意

适用于 Linux 的 Windows 子系统 (WSL) 不支持 MongoDB。要在 Linux 上运行 MongoDB,请使用受支持的 Linux 系统。

Oracle 为在运行 Hyper-V 的 Windows 主机上使用 VirtualBox 提供试验性支持。但是,Microsoft 不支持在 Hyper-V 上使用 VirtualBox。

Disable Hyper-V if you want to install MongoDB on Windows using VirtualBox.

在生产环境中部署MongoDB之前,请参阅《自管理部署的生产说明》文档,了解性能注意事项和配置建议。

MongoDB会日志诊断数据以协助进行故障排除。有关详细信息,请参阅全时诊断数据捕获。

在 Windows 上,要收集磁盘、CPU 和内存等系统数据,FTDC 需要以下群组的 Microsoft 访问权限:

  • 性能监控用户

  • Performance Log Users

如果运行mongodmongos 的用户不是管理员,请将其添加到这些群组中以日志FTDC 数据。有关更多信息,请参阅Microsoft文档

Follow these steps to install MongoDB Enterprise Edition unattended on Windows from the Windows command prompt/interpreter (cmd.exe) using msiexec.exe.

1

从以下链接下载MongoDB .msi 安装程序:

MongoDB 下载中心

  1. Version 下拉列表中选择要下载的 MongoDB 版本。

  2. Platform 下拉菜单中,选择 Windows

  3. Package 下拉菜单中,选择 msi

  4. 单击 Download(连接)。

2

重要

您必须以 Administrator 身份打开命令解释器。

使用 .msi 安装程序安装所有 MongoDB 二进制文件,包括 MongoDB Compass

在命令解释器中,前往包含 .msi 安装二进制文件的目录并运行:

msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.3-signed.msi

该操作将二进制文件安装到默认目录 C:\Program Files\MongoDB\Server\8.3\bin

要为这些可执行文件指定其他安装位置,请添加 INSTALLLOCATION 值。

msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.3-signed.msi ^
INSTALLLOCATION="C:\MongoDB\Server\8.3\"

To suppress the installation of MongoDB Compass, you must explicitly include the SHOULD_INSTALL_COMPASS="0" argument.

msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.3-signed.msi ^
SHOULD_INSTALL_COMPASS="0"

要安装特定的 MongoDB 组件集,您可以使用逗号分隔的列表在 ADDLOCAL 参数中指定它们,其中包括以下一个或多个组件集:

组件集名称
组件集中包含的二进制文件

ServerNoService

ServerService

mongod.exe 设置为 Windows 服务。

Router

MonitoringTools

ImportExportTools

MiscellaneousTools

mongodecrypt.exe, mongokerberos.exe, mongoldap.exe

例如,要使用旧版 mongo 客户端安装 MongoDB 服务器 (mongod.exe),然后将 MongoDB 服务器设置为 Windows 服务,请运行以下命令:

msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.3-signed.msi ^
ADDLOCAL="ServerService,LegacyClient" ^
SHOULD_INSTALL_COMPASS="0"

要在安装中包含 Compass,请删除 SHOULD_INSTALL_COMPASS="0"

您可以在安装过程中将 MongoDB 安装和配置为 Windows Service。MongoDB 服务会在安装成功后启动。

要启动或重新启动MongoDB服务,请使用“服务”控制台:

  1. 在“服务”控制台中,找到 MongoDB 服务。

  2. 右键单击 MongoDB 服务,然后单击Start Start (启动)。

1

关闭所有其他命令提示符,然后调用以下命令:

net start MongoDB
2

检查 MongoDB 日志文件中是否有以下行:

[initandlisten] waiting for connections on port 27017

在启动过程的输出中,您可能会看到一些不关键的警告。只要在 MongoDB 日志中看到这条信息,您便可以在初步评估 MongoDB 时安全地忽略这些警告。

3

如果尚未执行此操作,请按 mongosh 安装说明下载和安装 MongoDB Shell (mongosh)。

请务必在安装过程中将 mongosh.exe 二进制文件的路径添加到 PATH 环境变量中。

打开新的 Command Interpreter,然后输入 mongosh.exe 以连接 MongoDB。

要停止或暂停MongoDB服务,请使用“服务”控制台:

  1. 在“服务”控制台中,找到 MongoDB 服务。

  2. 右键单击MongoDB服务,然后单击 StopPause

You can also manage the service from the command line. To stop the MongoDB service from the command line, open a Windows command prompt/interpreter (cmd.exe) as an Administrator, and run the following command:

net stop MongoDB

To remove the MongoDB service, first use the Services console to stop the service. Then open a Windows command prompt/interpreter (cmd.exe) as an Administrator, and run the following command:

sc.exe delete MongoDB

Open a Windows command prompt/interpreter (cmd.exe) as an Administrator.

重要

您必须以 Administrator 身份打开命令解释器。

1

Create the data directory where MongoDB stores data. MongoDB's default data directory path is the absolute path \data\db on the drive from which you start MongoDB.

Command Interpreter 创建数据目录:

cd C:\
md "\data\db"
2

要启动 MongoDB,请运行 mongod.exe

"C:\Program Files\MongoDB\Server\8.3\bin\mongod.exe" --dbpath="c:\data\db"

The --dbpath option points to your database directory.

如果 MongoDB 数据库服务器运行正常,则Command Interpreter显示:

[initandlisten] waiting for connections

重要

Depending on the Windows Defender Firewall settings on your Windows host, Windows may display a Security Alert dialog box about blocking "some features" of C:\Program Files\MongoDB\Server\8.3\bin\mongod.exe from communicating on networks. To remedy this issue:

  1. 单击 Private Networks, such as my home or work network(连接)。

  2. 单击 Allow access(连接)。

要了解有关安全和 MongoDB 的更多信息,请参阅安全文档。

3

如果尚未执行此操作,请按 mongosh 安装说明下载和安装 MongoDB Shell (mongosh)。

请务必在安装过程中将 mongosh.exe 二进制文件的路径添加到 PATH 环境变量中。

打开新的 Command Interpreter,然后输入 mongosh.exe 以连接 MongoDB。

有关使用 mongosh.exe 连接到 mongod 例如连接在其他主机和/或端口上运行的 MongoDB 实例,请参阅连接到部署。

有关 CRUD(创建、读取、更新、删除)操作的信息,请参阅:

默认情况下,MongoDB 会以将 bindIp 设为 127.0.0.1 来启动,从而绑定到本地主机网络接口。这意味着 mongod.exe 只能接受来自同一计算机上运行的客户端的连接。远程客户端无法连接到 mongod.exe,且 mongod.exe 无法初始化副本集,除非将此值设为有效的网络接口。

该值可通过以下任一方式配置:

  • 在 MongoDB 配置文件中使用 bindIp,或

  • 通过命令行参数 --bind_ip

警告

将实例绑定到可公开访问的 IP 地址之前,必须保护集群免遭未经授权的访问。有关安全建议的完整列表,请参阅自管理部署的安全清单。至少应考虑启用身份验证强化网络基础设施。

有关配置bindIp的详细信息,请参阅自托管部署中的IP绑定。

如果您使用Windows安装程序 () 安装MongoDB.msi ,则.msi 会在同一发布系列中自动升级,例如从7.2.1 升级到7.2.2 。

升级完整发布系列(例如从 6.0 升级到 7.0)需要全新安装。

本教程中的所有命令行示例都使用MongoDB二进制文件的绝对路径。您可以将 C:\Program Files\MongoDB\Server\8.3\bin 添加到系统 PATH,以省略MongoDB二进制文件的完整路径。