Database Manual / Self-Managed Deployments / Installation / Enterprise

Install MongoDB Enterprise on macOS在macOS上安装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 manually install MongoDB 8.3 Enterprise Edition on macOS using a downloaded .tgz tarball.使用本教程,使用下载的.tgz tarball在macOS上手动安装MongoDB 8.3企业版。

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

MongoDB VersionMongoDB版本

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,请使用此页面左上角的版本下拉菜单选择该版本的文档。

Considerations注意事项

MongoDB Shell, mongosh

When you use the .tgz package to install the server, you need to follow the mongosh installation instructions to download and install mongosh separately.当您使用.tgz软件包安装服务器时,您需要按照mongosh安装说明单独下载和安装mongosh

Platform Support平台支持

MongoDB 8.3 Enterprise Edition supports macOS 11 or later.MongoDB 8.3企业版支持macOS 11或更高版本。

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

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部署提供了性能考虑和配置建议。

Install MongoDB Enterprise Edition安装MongoDB企业版

To manually install MongoDB Enterprise Edition from the .tgz, select the tab that corresponds with your Mac's processor and complete the following steps:要从.tgz手动安装MongoDB Enterprise Edition,请选择与Mac处理器对应的选项卡,并完成以下步骤:

intel
1

Download the tarball.下载tarball。

Download the MongoDB Enterprise tgz tarball from the following link:从以下链接下载MongoDB Enterprise tgz tarball:

MongoDB Download CenterMongoDB下载中心

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

Extract the files from the downloaded archive.从下载的存档中提取文件。

tar -zxvf mongodb-macos-x86_64-enterprise-8.3.tgz

If your web browser automatically unzips the file as part of the download, the file ends in .tar instead.如果web浏览器在下载过程中自动解压缩文件,则文件将以.tar结尾。

3

Ensure the binaries are in a directory listed in your PATH environment variable.确保二进制文件位于PATH环境变量中列出的目录中。

The MongoDB binaries are in the bin/ directory of the tarball. You can either:MongoDB二进制文件位于tarball的bin/目录中。您可以:

  • Copy the binaries into a directory listed in your PATH variable, such as /usr/local/bin. Replace /path/to/the/mongodb-directory/ with your installation directory.将二进制文件复制到PATH变量中列出的目录中,例如/usr/local/bin。将/path/to/the/mongodb-directory/替换为安装目录。

    sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/
  • Create symbolic links to the binaries from a directory listed in your PATH variable, such as /usr/local/bin. Replace /path/to/the/mongodb-directory/ with your installation directory.PATH变量中列出的目录(如/usr/local/bin)创建指向二进制文件的符号链接。将/path/to/the/mongodb-directory/替换为安装目录。

    sudo ln -s  /path/to/the/mongodb-directory/bin/* /usr/local/bin/
apple
1

Download the tarball.下载tarball。

Download the MongoDB Enterprise tgz tarball from the following link:从以下链接下载MongoDB Enterprise tgz tarball:

MongoDB Download Center

  1. In the Version dropdown, select the version of MongoDB to download.
  2. In the Platform dropdown, select macOS ARM 64.
  3. In the Package dropdown, select tgz.
  4. Click Download.
2

Extract the files from the downloaded archive.从下载的存档中提取文件。

tar -zxvf mongodb-macos-arm64-enterprise-8.3.tgz

If your web browser automatically unzips the file as part of the download, the file ends in .tar instead.如果web浏览器在下载过程中自动解压缩文件,则文件将以.tar结尾。

3

Ensure the binaries are in a directory listed in your PATH environment variable.确保二进制文件位于PATH环境变量中列出的目录中。

The MongoDB binaries are in the bin/ directory of the tarball. You can either:MongoDB二进制文件位于tarball的bin/目录中。您可以:

  • Copy the binaries into a directory listed in your PATH variable, such as /usr/local/bin. Replace /path/to/the/mongodb-directory/ with your installation directory.

    sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/
  • Create symbolic links to the binaries from a directory listed in your PATH variable, such as /usr/local/bin. Replace /path/to/the/mongodb-directory/ with your installation directory.PATH变量中列出的目录(如/usr/local/bin)创建指向二进制文件的符号链接。将/path/to/the/mongodb-directory/替换为安装目录。

    sudo ln -s  /path/to/the/mongodb-directory/bin/* /usr/local/bin/

Run MongoDB Enterprise Edition运行MongoDB企业版

ulimit Considerationsulimit注意事项
Most Unix-like operating systems limit the system resources that a process may use. These limits may negatively impact MongoDB operation, and should be adjusted. See UNIX ulimit Settings for Self-Managed Deployments for the recommended settings for your platform. 大多数类Unix操作系统限制了进程可能使用的系统资源。这些限制可能会对MongoDB的运行产生负面影响,应该进行调整。有关平台的推荐设置,请参阅UNIX ulimit自我管理部署设置

Note

If the ulimit value for number of open files is under 64000, MongoDB generates a startup warning.如果打开文件数的ulimit值低于64000,MongoDB会生成启动警告。

Procedure过程

Follow these steps to run MongoDB Enterprise Edition. These instructions assume that you are using the default settings.按照以下步骤运行MongoDB企业版。这些说明假定您正在使用默认设置。

1

Create the data directory.创建数据目录。

Before you start MongoDB for the first time, you must create the directory to which the mongod process will write data.在首次启动MongoDB之前,您必须创建mongod进程将写入数据的目录。

For example, to create the ~/data/db directory:

sudo mkdir -p ~/data/db
2

Create the log directory.创建日志目录。

You must also create the directory in which the mongod process will write its log file:您还必须创建mongod进程将在其中写入日志文件的目录:

For example, to create the ~/data/log/mongodb directory:例如,要创建~/data/log/mongodb目录:

sudo mkdir -p ~/data/log/mongodb
3

Set permissions for the data and log directories.设置数据和日志目录的权限。

Ensure that the user account running mongod has read and write permissions for these two directories. 确保运行mongod的用户帐户对这两个目录具有读写权限。If you are running mongod as your own user account, and you just created the two directories above, they should already accessible to your user. 如果你以自己的用户帐户运行mongod,并且你刚刚创建了上面的两个目录,那么用户应该已经可以访问它们了。Otherwise, you can use chown to set ownership, substituting the appropriate user:否则,您可以使用chown设置所有权,替换相应的用户:

sudo chown <user> ~/data/db
sudo chown <user> ~/data/log/mongodb
4

Run MongoDB.运行MongoDB。

To run MongoDB, run the mongod process at the system prompt, providing the two parameters dbpath and logpath from above, and the nohup command to run mongod in the background. 要运行MongoDB,请在系统提示符下运行mongod进程,提供上面的dbpathlogpath两个参数,并在后台运行nohup命令。Alternatively, you may choose to store the values for dbpath, logpath, and many other parameters in a configuration file.或者,您可以选择将dbpathlogpath和许多其他参数的值存储在配置文件中。

Run mongod with command-line parameters使用命令行参数运行mongod

Run the mongod process at the system prompt, providing the three necessary parameters directly on the command-line:在系统提示符下运行mongod进程,直接在命令行上提供三个必要的参数:

nohup mongod --dbpath ~/path/to/dbdir --logpath ~/path/to/mongodb.log >/dev/null &
Run mongod with a configuration file使用配置文件运行mongod

Run the mongod process at the system prompt, providing the path to a configuration file with the config parameter:在系统提示符下运行mongod进程,提供带有config参数的配置文件的路径:

mongod --config /usr/local/etc/mongod.conf

macOS may prevent mongod from running after installation. macOS可能会阻止mongod在安装后运行。If you receive a security error when starting mongod indicating that the developer could not be identified or verified, do the following to grant mongod access to run:如果在启动mongod时收到安全错误,表明无法识别或验证开发人员,请执行以下操作以授予mongod运行权限:

  • Open System Preferences打开系统首选项
  • Select the Security and Privacy pane.选择“安全和隐私”窗格。
  • Under the General tab, click the button to the right of the message about mongod, labelled either Open Anyway or Allow Anyway depending on your version of macOS.在“常规”选项卡下,单击有关mongod的消息右侧的按钮,根据macOS版本,标记为“无论如何打开”或“无论如何允许”。
5

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

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

ps aux | grep -v grep | grep mongod

If you do not see a mongod process running, check the logfile for any error messages.如果您没有看到mongod进程正在运行,请检查日志文件中是否有任何错误消息。

6

Begin using MongoDB.开始使用MongoDB。

Start a mongosh session on the same host machine as the mongod. 在与mongod相同的主机上启动mongosh会话。You can run mongosh without any command-line options to connect to a mongod that is running on your localhost with the default port of 27017:您可以在没有任何命令行选项的情况下运行mongosh,以连接到在本地主机上运行的mongod,默认端口为27017

mongosh

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

To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started with MongoDB for the available editions.为了帮助您开始使用MongoDB,MongoDB提供了各种驱动程序版本的入门指南。有关可用版本,请参阅MongoDB入门

Additional Information附加信息

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 can only accept connections from clients that are running on the same machine. 这意味着mongod只能接受来自在同一台机器上运行的客户端的连接。Remote clients will not be able to connect to the mongod, and the mongod will not be able to initialize a replica set unless this value is set to a valid network interface.远程客户端将无法连接到mongod,除非将此值设置为有效的网络接口,否则mongod将无法初始化副本集。

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

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