Docs 菜单
Docs 主页
/
MongoDB Manual
/ / / /

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

在此页面上

  • Overview
  • Considerations
  • 安装 MongoDB Enterprise 版
  • 以 Windows 服务的形式启动 MongoDB Enterprise
  • 停止 MongoDB Enterprise 版作为 Windows 服务
  • 删除作为 Windows 服务的 MongoDB Enterprise 版
  • 从命令解释器启动 MongoDB Enterprise Edition
  • 其他注意事项

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

MongoDB Enterprise 版可在部分平台上使用,并支持与安全和监控相关的多项功能。

本教程将安装MongoDB 8.0 Enterprise 版。要安装不同版本的MongoDB Enterprise,请使用此页面左上角的版本下拉菜单选择该版本的文档。

本教程使用命令行工具msiexec.exe在 Windows 上安装 MongoDB。要使用图形 MSI 安装程序安装 MongoDB,请参阅使用 MSI 安装程序安装 MongoDB。

MongoDB Shell ( mongosh ) 不随 MongoDB Server 一起安装。您需要按照mongosh 安装说明单独下载并安装mongosh

MongoDB 8.0 Enterprise 版支持 x 86 _ 64架构上的以下 64位版本的Windows :

  • Windows Server 2022

  • Windows Server 2019

  • 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 生产部署的性能注意事项和配置建议。

MongoDB 记录诊断数据以帮助排除故障。有关详细信息,请参阅全时诊断数据采集。

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

  • 性能监控用户

  • Performance Log Users

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

请按照以下步骤从 Windows 命令提示符/解释器 在 Windows 上无人值守地安装 MongoDB Enterprise 版 (cmd.exe )使用msiexec.exe

1

从以下链接下载 MongoDB Enterprise.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.0-signed.msi

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

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

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

如要阻止安装 MongoDB Compass,必须显式包含 SHOULD_INSTALL_COMPASS="0" 参数。

msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.0-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.0-signed.msi ^
ADDLOCAL="ServerService,LegacyClient" ^
SHOULD_INSTALL_COMPASS="0"

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

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

To start/restart the MongoDB service, use the Services console:

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

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

您还可以通过命令行手动管理该服务。要通过命令行启动 MongoDB 服务,请以 Administrator 身份打开 Windows 命令提示符/解释器 (cmd.exe),然后运行以下命令:

1

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

net start MongoDB
2

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

[initandlisten] waiting for connections on port 27017

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

3

如果尚未下载并安装 MongoDB Shell ( mongosh ),请按照 mongosh 安装说明 进行操作。

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

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

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

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

  2. 右键单击 MongoDB 服务,然后单击 Stop(停止)(或 Pause(暂停))。

您还可以通过命令行管理该服务。要通过命令行停止 MongoDB 服务,请以 Administrator 身份打开 Windows 命令提示符/解释器 (cmd.exe),然后运行以下命令:

net stop MongoDB

要删除 MongoDB 服务,请先使用“服务”控制台停止该服务。然后以 Administrator 的身份打开 Windows 命令提示符/解释器 (cmd.exe),并运行以下命令:

sc.exe delete MongoDB

Administrator 身份打开 Windows 命令提示/解释器 (cmd.exe)。

重要

您必须以 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.0\bin\mongod.exe" --dbpath="c:\data\db"

The --dbpath option points to your database directory.

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

[initandlisten] waiting for connections

重要

根据 Windows 主机上的 Windows Defender 防火墙设置,Windows 可能会显示一个 Security Alert 对话框,提示阻塞 C:\Program Files\MongoDB\Server\8.0\bin\mongod.exe 的“某些功能”在网络上进行通信。要解决此问题,请执行以下操作:

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

  2. 单击 Allow access(连接)。

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

3

如果尚未下载并安装 MongoDB Shell ( mongosh ),请按照 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 安装程序 (.msi) 安装了 MongoDB,则 .msi 将在同一版本系列中自动进行升级(例如从7.2.1 至 7.2.2)。

升级完整版本系列(例如6.0 至 7.0)需要全新安装。

本教程中的所有命令行示例均作为 MongoDB 二进制文件的绝对路径提供。您可以将C:\Program Files\MongoDB\Server\8.0\bin添加到系统PATH ,然后省略 MongoDB 二进制文件的完整路径。

后退

在 Windows 上安装