Database Manual / Self-Managed Deployments / Installation / Enterprise

Install MongoDB Enterprise Edition on Windows在Windows上安装MongoDB企业版

Warning

MongoDB 8.3 Not Yet AvailableMongoDB 8.3尚未推出

MongoDB 8.3 release candidates are not yet available. This version of the manual is for an upcoming release and is currently a work in progress.MongoDB 8.3候选版本尚未发布。此版本的手册适用于即将发布的版本,目前正在进行中。

Important

MongoDB 8.3 is the latest minor release. Starting with MongoDB 8.2, minor releases are available for on-premises deployments (Community and EA) for specific use cases. For more information, see MongoDB Versioning.MongoDB 8.3是最新的次要版本。从MongoDB 8.2开始,次要版本可用于特定用例的本地部署(社区和EA)。有关更多信息,请参阅MongoDB版本控制

To install the latest MongoDB version supported for on-premises use, see the installation instructions.要安装支持本地使用的最新MongoDB版本,请参阅安装说明

Overview概述

Use this tutorial to install MongoDB 8.3 Enterprise Edition on Windows using the default installation wizard.使用本教程,使用默认安装向导在Windows上安装MongoDB 8.3企业版。

MongoDB Enterprise Edition企业版 is available on select platforms and contains support for several features related to security and monitoring.在特定平台上可用,并包含对与安全和监控相关的几个功能的支持。

MongoDB Version版本

This tutorial installs MongoDB 8.3 Enterprise Edition. To install a different version of MongoDB Enterprise, use the version drop-down menu in the upper-left corner of this page to select the documentation for that version.本教程安装MongoDB 8.3企业版。要安装不同版本的MongoDB Enterprise,请使用此页面左上角的版本下拉菜单选择该版本的文档。

Installation Method安装方法

This tutorial installs MongoDB on Windows using the default MSI installation wizard. To install MongoDB using the msiexec.exe command-line tool instead, see Install MongoDB using msiexec.exe. 本教程使用默认的MSI安装向导在Windows上安装MongoDB。要改用msiexec.exe命令行工具安装MongoDB,请参阅使用msiexec.exe安装MongoDBThe msiexec.exe tool is useful for system administrators who wish to deploy MongoDB in an unattended fashion using automation.msiexec.exe工具对于希望使用自动化以无人值守的方式部署MongoDB的系统管理员非常有用。

Considerations注意事项

MongoDB Shell, mongosh

The MongoDB Shell (mongosh) is not installed with MongoDB Server. 该MongoDB Shell(mongosh)未与MongoDB Server一起安装。You need to follow the mongosh installation instructions to download and install mongosh separately.您需要按照mongosh安装说明单独下载和安装mongosh

Platform Support平台支持

MongoDB 8.3 Enterprise Edition supports the following 64-bit versions of Windows on x86_64 architecture:MongoDB 8.3企业版在x86_64架构上支持以下64位版本的Windows:

  • Windows Server 2022
  • Windows Server 2019
  • Windows 11

MongoDB only supports the 64-bit versions of these platforms.MongoDB只支持这些平台的64位版本。

For more information, see Platform Support.有关更多信息,请参阅平台支持

Note

MongoDB is not supported on Windows Subsystem for Linux (WSL). To run MongoDB on Linux, use a supported Linux system.Windows Linux子系统(WSL)不支持MongoDB。要在Linux上运行MongoDB,请使用受支持的Linux系统。

Virtualization虚拟化

Oracle offers experimental support for VirtualBox on Windows hosts where Hyper-V is running. Oracle在运行Hyper-V的Windows主机上为VirtualBox提供了实验性支持However, Microsoft does not support VirtualBox on Hyper-V.但是,Microsoft不支持Hyper-V上的VirtualBox

Disable Hyper-V if you want to install MongoDB on Windows using VirtualBox.如果要使用VirtualBox在Windows上安装MongoDB,请禁用Hyper-V。

Production Notes制作说明

Before deploying MongoDB in a production environment, consider the Production Notes for Self-Managed Deployments document which offers performance considerations and configuration recommendations for production MongoDB deployments.在生产环境中部署MongoDB之前,请考虑《自我管理部署的生产说明》文档,该文档为生产MongoDB部署提供了性能考虑和配置建议。

Full Time Diagnostic Data Capture全职诊断数据采集

MongoDB logs diagnostic data to assist with troubleshooting. For detailed information, see Full Time Diagnostic Data Capture.MongoDB记录诊断数据以协助故障排除。有关详细信息,请参阅全职诊断数据捕获

On Windows, to collect system data such as disk, cpu, and memory, FTDC requires Microsoft access permissions from the following groups:在Windows上,要集合磁盘、cpu和内存等系统数据,FTDC需要以下组的Microsoft访问权限:

  • Performance Monitor Users性能监视器用户
  • Performance Log Users性能日志用户

If the user running mongod and mongos is not an administrator, add them to these groups to log FTDC data. 如果运行mongodmongos的用户不是管理员,请将它们添加到这些组中以记录FTDC数据。For more information, see the Microsoft documentation here.有关详细信息,请参阅此处的Microsoft文档

Install MongoDB Enterprise Edition安装MongoDB企业版

Procedure过程

Follow these steps to install MongoDB Enterprise Edition using the Windows Installation wizard. 按照以下步骤使用Windows安装向导安装MongoDB Enterprise Edition。The installation process installs both the MongoDB binaries as well as the default configuration file <install directory>\bin\mongod.cfg.安装过程安装MongoDB二进制文件以及默认配置文件<install directory>\bin\mongod.cfg

1

Download the installer.下载安装程序。

Download the MongoDB Enterprise .msi installer from the following link:从以下链接下载MongoDB Enterprise msi安装程序:

MongoDB Download Center

  1. In the Version dropdown, select the version of MongoDB to download.在“版本”下拉列表中,选择要下载的MongoDB版本。
  2. In the Platform dropdown, select Windows.在“平台”下拉列表中,选择Windows。
  3. In the Package dropdown, select msi.在“包”下拉列表中,选择msi
  4. Click Download.单击“下载”。
2

Run the MongoDB installer.运行MongoDB安装程序。

For example, from the Windows Explorer/File Explorer:例如,在Windows资源管理器/文件资源管理器中:

  1. Go to the directory where you downloaded the MongoDB installer (.msi file). By default, this is your Downloads directory.转到下载MongoDB安装程序(.msi文件)的目录。默认情况下,这是你的下载目录。
  2. Double-click the .msi file.双击.msi文件。
3

Follow the MongoDB Enterprise Edition installation wizard.按照MongoDB企业版安装向导进行操作。

The wizard steps you through the installation of MongoDB and MongoDB Compass.该向导将指导您完成MongoDB和MongoDB Compass的安装。

  1. Choose Setup Type
    You can choose either the Complete (recommended for most users) or Custom setup type. The Complete setup option installs MongoDB and the MongoDB tools to the default location. 您可以选择完整(建议大多数用户使用)或自定义设置类型。完整设置选项将MongoDB和MongoDB工具安装到默认位置。The Custom setup option allows you to specify which executables are installed and where.自定义设置选项允许您指定安装哪些可执行文件以及安装位置。
  2. Service Configuration服务配置

    You can set up MongoDB as a Windows service during the install or just install the binaries.您可以在安装过程中将MongoDB设置为Windows服务,也可以只安装二进制文件。

    MongoDB Service

    You can configure and start MongoDB as a Windows service during the install, and the MongoDB service is started upon successful installation.您可以在安装过程中将MongoDB配置为Windows服务并启动,MongoDB服务将在安装成功后启动。

    • Select Install MongoD as a Service.
    • Select one of these options:选择以下选项之一:

      • Run the service as Network Service user以网络服务用户身份运行服务 (Default)

        This is a Windows user account that is built-in to Windows.这是Windows内置的Windows用户帐户。

      • Run the service as a local or domain user以本地或域用户身份运行服务

        • For an existing local user account, specify a period (.) for the Account Domain and specify the Account Name and the Account Password for the user.对于现有的本地用户帐户,为帐户域指定一个句点(.),并为用户指定帐户名和帐户密码。
        • For an existing domain user, specify the Account Domain, Account Name and Account Password for that user.对于现有域用户,指定该用户的帐户域、帐户名和帐户密码。
    • Service Name. Specify the service name. Default name is MongoDB. If you already have a service with the specified name, you must choose another name.服务名称。指定服务名称。默认名称为MongoDB。如果您已经有一个具有指定名称的服务,则必须选择另一个名称。
    • Data Directory. Specify the data directory, which corresponds to the --dbpath. 数据目录。指定与--dbpath对应的数据目录。If the directory does not exist, the installer will create the directory and sets the directory access to the service user.如果目录不存在,安装程序将创建目录并将目录访问权限设置为服务用户。
    • Log Directory. Specify the Log directory, which corresponds to the --logpath. 日志目录。指定Log目录,该目录对应于--logpathIf the directory does not exist, the installer will create the directory and sets the directory access to the service user.如果目录不存在,安装程序将创建目录并将目录访问权限设置为服务用户。
    MongoDB

    If you choose not to configure MongoDB as a Windows service, uncheck the Install MongoD as a Service.如果您选择不将MongoDB配置为Windows服务,请取消选中“将MongoD安装为服务”。

  3. Install安装 MongoDB Compass
    Optional. To have the wizard install MongoDB Compass, select Install MongoDB Compass (Default).可选。要让向导安装MongoDB Compass,请选择安装MongoDB Compass(默认)。
  4. When ready, click Install.准备就绪后,单击“安装”。

If You Installed MongoDB as a Windows Service如果您将MongoDB安装为Windows服务

The MongoDB service starts upon successful installation. MongoDB服务在成功安装后启动。Configure the MongoDB instance with the configuration file <install directory>\bin\mongod.cfg.使用配置文件<install directory>\bin\mongod.cfg配置MongoDB实例。

If you have not already done so, follow the mongosh installation instructions to download and install the MongoDB Shell (mongosh).如果您还没有这样做,请按照mongosh安装说明下载并安装MongoDB Shell(mongosh

Be sure to add the path to your mongosh.exe binary to your PATH environment variable during installation.在安装过程中,一定要将mongosh.exe二进制文件的路径添加到PATH环境变量中。

Open a new Command Interpreter and enter mongosh.exe to connect to MongoDB.打开一个新的命令解释器,输入mongosh.exe连接到MongoDB。

For more information on connecting to mongod using mongosh.exe, such as connecting to a MongoDB instance running on a different host and/or port, see Connect to a Deployment.有关使用mongosh.exe连接到mongod的更多信息,例如连接到在不同主机和/或端口上运行的MongoDB实例,请参阅连接到部署

For information on CRUD (Create, Read, Update, Delete) operations, see:有关CRUD(创建、读取、更新、删除)操作的信息,请参阅:

If You Did Not Install MongoDB as a Windows Service如果您没有将MongoDB安装为Windows服务

If you only installed the executables and did not install MongoDB as a Windows service, you must manually start the MongoDB instance.如果您只安装了可执行文件,而没有将MongoDB作为Windows服务安装,则必须手动启动MongoDB实例。

See Start MongoDB Enterprise Edition from the Command Interpreter for instructions to start a MongoDB instance.有关启动MongoDB实例的说明,请参阅从命令解释器启动MongoDB企业版

Start MongoDB Enterprise Edition from the Command Interpreter从命令解释器启动MongoDB企业版

1

Create database directory.创建数据库目录。

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.创建MongoDB存储数据的数据目录。MongoDB的默认数据目录路径是启动MongoDB的驱动器上的绝对路径\data\db

From the Command Interpreter, create the data directories:在命令解释器中,创建数据目录:

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

Start your MongoDB database.启动MongoDB数据库。

To start MongoDB, run mongod.exe.要启动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.--dbpath选项指向数据库目录。

If the MongoDB database server is running correctly, the Command Interpreter displays:如果MongoDB数据库服务器运行正常,命令解释器将显示:

[initandlisten] waiting for connections

Important

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. 根据Windows主机上的Windows Defender防火墙设置,Windows可能会显示一个安全警报对话框,阻止C:\Program Files\MongoDB\Server\8.3\bin\mongod.exe的“某些功能”在网络上通信。To remedy this issue:要解决此问题,请执行以下操作:

  1. Click Private Networks, such as my home or work network.单击“专用网络”,例如我的家庭或工作网络。
  2. Click Allow access.单击“允许访问”。

To learn more about security and MongoDB, see the Security Documentation.要了解有关安全性和MongoDB的更多信息,请参阅安全文档

3

Connect to MongoDB.连接到MongoDB。

If you have not already done so, follow the mongosh installation instructions to download and install the MongoDB Shell (mongosh).如果您还没有这样做,请按照mongosh安装说明下载并安装MongoDB Shell(mongosh)。

Be sure to add the path to your mongosh.exe binary to your PATH environment variable during installation.在安装过程中,一定要将mongosh.exe二进制文件的路径添加到PATH环境变量中。

Open a new Command Interpreter and enter mongosh.exe to connect to MongoDB.打开一个新的命令解释器,输入mongosh.exe连接到MongoDB。

For more information on connecting to mongod using mongosh.exe, such as connecting to a MongoDB instance running on a different host and/or port, see Connect to a Deployment.有关使用mongosh.exe连接到mongod的更多信息,例如连接到在不同主机和/或端口上运行的MongoDB实例,请参阅连接到部署

For information on CRUD (Create, Read, Update, Delete) operations, see:有关CRUD(创建、读取、更新、删除)操作的信息,请参阅:

Start MongoDB Enterprise Edition as a Windows Service将MongoDB企业版作为Windows服务启动

Starting in version 4.0, you can install and configure MongoDB as a Windows Service during the install, the MongoDB service starts upon successful installation.从4.0版本开始,您可以在安装过程中将MongoDB作为Windows服务进行安装和配置。安装成功后,MongoDB服务将启动。

To start/restart the MongoDB service, use the Services console:要启动/重新启动MongoDB服务,请使用Services控制台:

  1. From the Services console, locate the MongoDB service.在Services控制台中,找到MongoDB服务。
  2. Right-click on the MongoDB service and click Start.右键单击MongoDB服务,然后单击启动。

You can also manually manage the service from the command line. To start the MongoDB service from the command line, open a Windows command prompt/interpreter (cmd.exe) as an Administrator, and run the following command:您还可以从命令行手动管理该服务。要从命令行启动MongoDB服务,请以“管理员”身份打开Windows命令提示符/解释器(cmd.exe),然后运行以下命令:

1

Start the MongoDB service.启动MongoDB服务。

Close all other command prompts, then invoke the following command:关闭所有其他命令提示,然后调用以下命令:

net start MongoDB
2

Verify that MongoDB has started successfully.验证MongoDB是否已成功启动。

Check your MongoDB log file for the following line:检查MongoDB日志文件中的以下行:

[initandlisten] waiting for connections on port 27017

You may see non-critical warnings in the process output. As long as you see this message in the MongoDB log, you can safely ignore these warnings during your initial evaluation of MongoDB.您可能会在流程输出中看到非严重警告。只要您在MongoDB日志中看到此消息,您就可以在对MongoDB进行初始评估时安全地忽略这些警告。

3

Connect to the MongoDB server.连接到MongoDB服务器。

If you have not already done so, follow the mongosh installation instructions to download and install the MongoDB Shell (mongosh).如果您还没有这样做,请按照mongosh安装说明下载并安装MongoDB Shell(mongosh)。

Be sure to add the path to your mongosh.exe binary to your PATH environment variable during installation.在安装过程中,一定要将mongosh.exe二进制文件的路径添加到path环境变量中。

Open a new Command Interpreter and enter mongosh.exe to connect to MongoDB.打开一个新的命令解释器,输入mongosh.exe连接到MongoDB。

Stop MongoDB Enterprise Edition as a Windows Service停止MongoDB企业版作为Windows服务

To stop/pause the MongoDB service, use the Services console:要停止/暂停MongoDB服务,请使用Services控制台:

  1. From the Services console, locate the MongoDB service.在Services控制台中,找到MongoDB服务。
  2. Right-click on the MongoDB service and click Stop (or Pause).右键单击MongoDB服务,然后单击停止(或暂停)。

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:要从命令行停止MongoDB服务,请以管理员身份打开Windows命令提示符/解释器(cmd.exe,然后运行以下命令:

net stop MongoDB

Remove MongoDB Enterprise Edition as a Windows Service将MongoDB企业版作为Windows服务删除

To remove the MongoDB service, first use the Services console to stop the service. 要删除MongoDB服务,首先使用Services控制台停止服务。Then open a Windows command prompt/interpreter (cmd.exe) as an Administrator, and run the following command:然后以管理员身份打开Windows命令提示符/解释器(cmd.exe,并运行以下命令:

sc.exe delete MongoDB

Additional Considerations补充说明

Localhost Binding by Default默认本地主机绑定

By default, MongoDB launches with bindIp set to 127.0.0.1, which binds to the localhost network interface. 默认情况下,MongoDB启动时bindIp设置为127.0.0.1,绑定到localhost网络接口。This means that the mongod.exe can only accept connections from clients that are running on the same machine. 这意味着mongod.exe只能接受来自在同一台机器上运行的客户端的连接。Remote clients will not be able to connect to the mongod.exe, and the mongod.exe will not be able to initialize a replica set unless this value is set to a valid network interface.远程客户端将无法连接到mongod.exe,除非将此值设置为有效的网络接口,否则mongod.exe将无法初始化副本集。

This value can be configured either:此值可以配置为:

  • in the MongoDB configuration file with bindIp, or在带有bindIp的MongoDB配置文件中,或
  • via the command-line argument --bind_ip通过命令行参数--bind_ip

Warning

Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. 在将实例绑定到可公开访问的IP地址之前,必须保护集群免受未经授权的访问。For a complete list of security recommendations, see Security Checklist for Self-Managed Deployments. 有关安全建议的完整列表,请参阅自我管理部署的安全检查表At minimum, consider enabling authentication and hardening network infrastructure.至少,考虑启用身份验证加强网络基础设施

For more information on configuring bindIp, see IP Binding in Self-Managed Deployments.有关配置bindIp的更多信息,请参阅自我管理部署中的IP绑定

Point Releases and .msi点发布和.msi

If you installed MongoDB with the Windows installer (.msi), that .msi automatically upgrades within its release series (e.g. 4.2.1 to 4.2.2).如果您使用Windows安装程序(.msi)安装了MongoDB,.msi会自动在其版本系列(例如4.2.1到4.2.2)中升级。

Upgrading a full release series (e.g. 4.0 to 4.2) requires a new installation.升级完整版本系列(例如4.0到4.2)需要新的安装。

Add MongoDB binaries to the System PATH将MongoDB二进制文件添加到系统PATH

All command-line examples in this tutorial are provided with absolute paths to the MongoDB binaries. 本教程中的所有命令行示例都提供了MongoDB二进制文件的绝对路径。You can add C:\Program Files\MongoDB\Server\8.3\bin to your System PATH and then omit the full path to the MongoDB binaries.您可以将C:\Program Files\MongoDB\Server\8.3\bin添加到系统PATH中,然后省略MongoDB二进制文件的完整路径。