Database Manual / Self-Managed Deployments / Installation / Enterprise / Install on Windows

Install MongoDB Enterprise on Windows From a Zip File从Zip文件在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 by downloading and extracting the zip file.使用本教程通过下载并解压缩zip文件在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 by extracting from a zip file. You can also install MongoDB on Windows by these other methods:本教程通过从zip文件中提取来在Windows上安装MongoDB。您还可以通过以下其他方法在Windows上安装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 from the zip file.按照以下步骤从zip文件安装MongoDB企业版。

1

Download MongoDB Enterprise Edition.下载MongoDB企业版。

Download the MongoDB Enterprise .zip file from the following link:从以下链接下载MongoDB企业版.zip文件:

MongoDB Download Center下载中心

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

Extract the MongoDB files.提取MongoDB文件。

  1. Go to the directory where you downloaded the MongoDB .zip file. By default, this is your Downloads directory.转到下载MongoDB .zip文件的目录。默认情况下,这是“下载”目录。
  2. Double-click the .zip file.双击.zip文件。
  3. Extract the files to your preferred location. For example, you may want to use C:\MongoDB.将文件解压缩到首选位置。例如,您可能希望使用C:\MongoDB
3

Create Configuration File (Optional).创建配置文件(可选)。

You can create a configuration file to specify options for MongoDB. 您可以创建一个配置文件来指定MongoDB的选项。To do so, create a file named mongod.cfg in the \bin\ directory within the directory where you extracted the MongoDB files (<install directory>\bin\mongod.cfg). 为此,请在解压缩MongoDB文件的目录(<install directory>\bin\mongod.cfg)中的\bin\目录中创建一个名为mongod.cfg的文件。For more information on creating a config file, see Configuration File.有关创建配置文件的更多信息,请参阅配置文件

4

Create Required and Optional Directories.创建必需和可选目录。

  1. MongoDB needs a data directory to store your data. MongoDB需要一个数据目录来存储数据。By default, it uses C:\data\db, but you may specify a different location in your config file. You can create the data directory using the Windows Command Prompt:默认情况下,它使用C:\data\db,但您可以在配置文件中指定其他位置。您可以使用Windows命令提示符创建数据目录:

    mkdir c:\data\db
  2. If you specified a log path in the configuration file, create the log directory in the same way.如果在配置文件中指定了日志路径,请以相同的方式创建日志目录。

Configure MongoDB Enterprise Edition as a Windows Service将MongoDB企业版配置为Windows服务

You can install and configure MongoDB as a Windows Service. To do so, follow these steps:您可以将MongoDB安装并配置为Windows服务。为此,请按照以下步骤操作:

  1. Add <install directory>\bin to your PATH environment variable.<installdirectory>\bin添加到PATH环境变量中。
  2. Open a Windows Command prompt as an Administrator, change to your MongoDB install directory, and run mongod with the --dbpath, --logpath and --install parameters. 管理员身份打开Windows命令提示符,切换到MongoDB安装目录,并使用--dbpath--logpath--install参数运行mongodFor example, the following command installs MongoDB as a service that uses C:\data\db for its data location and C:\data\log.txt for the log file:例如,以下命令将MongoDB安装为一个服务,该服务使用C:\data\db作为其数据位置,使用C:\data\log.txt作为日志文件:

    mongod --dbpath=C:\data\db --logpath=C:\data\log.txt --install

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

To manually start or 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

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

Open a Windows command prompt/interpreter (cmd.exe) as an Administrator.以管理员身份打开Windows命令提示符/解释器cmd.exe)。

Important

You must open the command interpreter as an Administrator.您必须以管理员身份打开命令解释器。

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(创建、读取、更新、删除)操作的信息,请参阅:

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

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

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

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

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

All command-line examples in this tutorial are provided as absolute paths to the MongoDB binaries. 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.本教程中的所有命令行示例都是作为MongoDB二进制文件的绝对路径提供的。您可以将C:\Program Files\MongoDB\Server\8.3\bin添加到系统PATH中,然后省略MongoDB二进制文件的完整路径。