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 in an unattended fashion using 使用本教程从命令行使用msiexec.exe from the command line. This is useful for system administrators who wish to deploy MongoDB using automation.msiexec.exe以无人值守的方式在Windows上安装MongoDB 8.3企业版。这对于希望使用自动化部署MongoDB的系统管理员非常有用。
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企业版,请使用此页面左上角的版本下拉菜单选择该版本的文档。
Installation Method安装方法
This tutorial installs MongoDB on Windows using the command-line tool 本教程使用命令行工具msiexec.exe. You can also install MongoDB on Windows by these other methods:msiexec.exe在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. For more information, see the Microsoft documentation here.mongod和mongos的用户不是管理员,请将它们添加到这些组中以记录FTDC数据。有关详细信息,请参阅此处的Microsoft文档。
Install MongoDB Enterprise Edition安装MongoDB企业版
Procedure过程
Follow these steps to install MongoDB Enterprise Edition unattended on Windows from the Windows command prompt/interpreter (按照以下步骤,使用cmd.exe) using msiexec.exe.msiexec.exe从Windows命令提示符/解释器(cmd.exe)在Windows上无人值守地安装MongoDB企业版。
Download MongoDB Enterprise Edition.下载MongoDB企业版。
Download the MongoDB Enterprise 从以下链接下载MongoDB Enterprise .msi installer from the following link:.msi安装程序:
In the Version dropdown, select the version of MongoDB to download.在版本下拉列表中,选择要下载的MongoDB版本。In the Platform dropdown, select Windows.在“平台”下拉列表中,选择Windows。In the Package dropdown, select msi.在“包”下拉列表中,选择msi。Click Download.单击“下载”。
Run the Windows Installer from the Windows Command Interpreter.从Windows命令解释器运行Windows Installer。
Important
You must open the command interpreter as an Administrator.您必须以管理员身份打开命令解释器。
Use the 使用.msi installer to install all MongoDB binaries, including MongoDB Compass..msi安装程序安装所有MongoDB二进制文件,包括MongoDB Compass。
From the Command Interpreter, go to the directory containing the 从命令解释器中,转到包含.msi installation binary and run:.msi安装二进制文件的目录并运行:
msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.3-signed.msi
The operation installs the binaries to the default directory 该操作将二进制文件安装到默认目录C:\Program Files\MongoDB\Server\8.3\bin.C:\Program Files\MongoDB\Server\8.3\bin。
To specify a different installation location for the executables, add the 要为可执行文件指定其他安装位置,请添加INSTALLLOCATION value.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 要禁止安装MongoDB Compass,必须显式包含SHOULD_INSTALL_COMPASS="0" argument.SHOULD_INSTALL_COMPASS="0"参数。
msiexec.exe /l*v mdbinstall.log /qb /i mongodb-windows-x86_64-enterprise-8.3-signed.msi ^
SHOULD_INSTALL_COMPASS="0"
To install specific MongoDB component sets, you can specify them in the 要安装特定的MongoDB组件集,您可以在ADDLOCAL argument using a comma-separated list including one or more of the following component sets:ADDLOCAL参数中使用逗号分隔的列表指定它们,该列表包括以下一个或多个组件集:
ServerNoService | mongod.exe |
ServerService | Set up mongod.exe as a Windows service. |
Router | mongos.exe |
MonitoringTools | mongostat.exe, mongotop.exe |
ImportExportTools | mongodump.exe, mongorestore.exe, mongoexport.exe, mongoimport.exe |
MiscellaneousTools | mongodecrypt.exe, mongokerberos.exe, mongoldap.exe |
For example, to install the MongoDB server (例如,要使用旧版mongo客户端安装MongoDB服务器(mongod.exe) with the legacy mongo client and then set up the MongoDB server as a Windows service, run: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"
To include Compass in the installs, remove 要在安装中包含Compass,请删除SHOULD_INSTALL_COMPASS="0".SHOULD_INSTALL_COMPASS="0"。
Start MongoDB Enterprise Edition as a Windows Service将MongoDB企业版作为Windows服务启动
You can install and configure MongoDB as a Windows Service during the install, and the MongoDB service starts upon successful installation.您可以在安装过程中将MongoDB安装并配置为Windows服务,MongoDB服务将在成功安装后启动。
To start/restart the MongoDB service, use the Services console:要启动/重新启动MongoDB服务,请使用Services控制台:
From the Services console, locate the MongoDB service.在Services控制台中,找到MongoDB服务。Right-click on the MongoDB service and click Start.右键单击MongoDB服务,然后单击启动。
Start the MongoDB service.启动MongoDB服务。
Close all other command prompts, then invoke the following command:关闭所有其他命令提示,然后调用以下命令:
net start MongoDBVerify 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进行初始评估时安全地忽略这些警告。
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控制台:
From the Services console, locate the MongoDB service.在Services控制台中,找到MongoDB服务。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 (您还可以从命令行管理该服务。要从命令行停止MongoDB服务,请以管理员身份打开Windows命令提示符/解释器(cmd.exe) as an Administrator, and run the following command:cmd.exe),然后运行以下命令:
net stop MongoDBRemove 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 (然后以管理员身份打开Windows命令提示符/解释器(cmd.exe) as an Administrator, and run the following command:cmd.exe),并运行以下命令:
sc.exe delete MongoDBStart MongoDB Enterprise Edition from the Command Interpreter从命令解释器启动MongoDB企业版
Open a Windows command prompt/interpreter (以管理员身份打开Windows命令提示符/解释器(cmd.exe) as an Administrator.cmd.exe)。
Important
You must open the command interpreter as an Administrator.您必须以管理员身份打开命令解释器。
Create database directory.创建数据库目录。
Create the data directory where MongoDB stores data. MongoDB's default data directory path is the absolute path 创建MongoDB存储数据的数据目录。MongoDB的默认数据目录路径是启动MongoDB的驱动器上的绝对路径\data\db。\data\db on the drive from which you start MongoDB.
From the Command Interpreter, create the data directories:在命令解释器中,创建数据目录:
cd C:\
md "\data\db"Start your MongoDB database.启动MongoDB数据库。
To start MongoDB, run 要启动MongoDB,请运行mongod.exe.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 根据Windows主机上的Windows Defender防火墙设置,Windows可能会显示一个安全警报对话框,阻止C:\Program Files\MongoDB\Server\8.3\bin\mongod.exe from communicating on networks. To remedy this issue:C:\Program Files\MongoDB\Server\8.3\bin\mongod.exe的“某些功能”在网络上通信。要解决此问题,请执行以下操作:
Click Private Networks, such as my home or work network.单击“专用网络”,例如我的家庭或工作网络。Click Allow access.单击“允许访问”。
To learn more about security and MongoDB, see the Security Documentation.要了解有关安全性和MongoDB的更多信息,请参阅安全文档。
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 有关使用mongosh.exe连接到mongod using mongosh.exe, such as connecting to a MongoDB instance running on a different host and/or port, see Connect to a Deployment.mongod的更多信息,例如连接到在不同主机和/或端口上运行的MongoDB实例,请参阅连接到部署。
For information on CRUD (Create, Read, Update, Delete) operations, see:有关CRUD(创建、读取、更新、删除)操作的信息,请参阅:
Additional Considerations补充说明
Localhost Binding by Default默认本地主机绑定
By default, MongoDB launches with 默认情况下,MongoDB启动时bindIp set to 127.0.0.1, which binds to the localhost network interface. This means that the mongod.exe can only accept connections from clients that are running on the same machine. bindIp设置为127.0.0.1,绑定到localhost网络接口。这意味着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, orbindIp的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 (如果您使用Windows安装程序(.msi), the .msi automatically upgrades within the same release series (e.g. 7.2.1 to 7.2.2)..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. 本教程中的所有命令行示例都是作为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二进制文件的完整路径。