对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

升级至 MongoDB Enterprise(分片集群)

MongoDB Enterprise 提供 MongoDB Community 版本中不提供的各种功能,例如:

以下步骤概述了将分片集群从 MongoDB Community Edition 升级到 MongoDB Enterprise Edition 的过程。例如,这些步骤可用于将 MongoDB 7.0 Community 升级到 MongoDB 7.0 Enterprise。

警告

请勿使用这些说明升级到其他发布版本。

For general guidance on MongoDB version numbering, release types, and upgrade paths, see MongoDB Versions and Upgrade Paths.

根据您的操作系统,您可以使用包管理器安装 MongoDB Enterprise 二进制文件,或手动下载该二进制文件。

如果您已使用包管理器安装了 MongoDB Community,请按照适合您操作系统的包管理器说明进行操作:

在安装过程中,包管理器将删除社区包;在重新启动之前,这不会影响正在运行的部署。

为了最大限度地减少停机时间,您可以使用“滚动”升级从 MongoDB Community 升级到企业版,即在其他节点可用时单独升级节点。

1

Connect mongosh to a mongos instance in the sharded cluster, and run sh.stopBalancer() to disable the balancer:

sh.stopBalancer()

注意

如果迁移正在进行,系统将在停止负载均衡器之前完成进行中的迁移。你可以运行 sh.isBalancerRunning() 以检查负载均衡器的当前状态。

要验证是否禁用了负载均衡器,请运行 sh.getBalancerState();如果已禁用负载均衡器,则会返回 false:

sh.getBalancerState()

从 MongoDB 6.0.3 开始,不再执行自动数据块分割。这是因为均衡策略的改进。自动分割命令仍然存在,但不执行操作。

在 6.0.3 之前的 MongoDB 版本中,sh.stopBalancer() 还会禁用分片集群的自动拆分。

有关禁用负载均衡器的更多信息,请参阅禁用负载均衡器。

2
  1. 逐个升级副本集的从节点成员:

    1. 关闭从节点 mongod 实例。

    2. 使用 Enterprise mongod 重新启动节点,指定相同的配置选项(例如相同的数据目录、配置文件等)。

    3. Wait for the member to recover to SECONDARY state before upgrading the next secondary member. To check the member's state, issue rs.status() in mongosh.

    对每个剩余的从节点重复上述操作。

  2. 降级副本集主节点。

    Connect mongosh to the primary and use rs.stepDown() to step down the primary and force an election of a new primary:

    rs.stepDown()
  3. 当 rs.status() 显示主节点已降级,并且另一个节点成为主节点时,升级已降级的主节点:

    1. 关闭降级主节点。

    2. 使用 Enterprise mongod 重新启动,指定相同的配置选项(例如 相同的数据目录、配置文件等)。

3

一次升级一个分片。

对于每个分片副本集:

  1. 逐个升级副本集的从节点成员:

    1. 关闭从节点 mongod 实例。

    2. 使用 Enterprise mongod 重新启动节点,指定相同的配置选项(例如相同的数据目录、配置文件等)。

    3. Wait for the member to recover to SECONDARY state before upgrading the next secondary member. To check the member's state, issue rs.status() in mongosh.

    对每个剩余的从节点重复上述操作。

  2. 降级副本集主节点。

    Connect mongosh to the primary and use rs.stepDown() to step down the primary and force an election of a new primary:

    rs.stepDown()
  3. 当 rs.status() 显示主节点已降级,并且另一个节点成为主节点时,升级已降级的主节点:

    1. 关闭降级主节点。

    2. 使用 Enterprise mongod 重新启动,指定相同的配置选项(例如 相同的数据目录、配置文件等)。

4

对于每个 mongos 实例,关闭 mongos 并使用企业版 mongos 重新启动,指定相同的配置选项。

5

Using mongosh, connect to a mongos in the cluster and run sh.startBalancer() to re-enable the balancer:

sh.startBalancer()

从 MongoDB 6.0.3 开始,不再执行自动数据块分割。这是因为均衡策略的改进。自动分割命令仍然存在,但不执行操作。

在 6.0.3 之前的 MongoDB 版本中,sh.startBalancer() 还支持分片集群的自动拆分。

有关负载均衡器的更多信息,请参阅启用负载均衡器。

重要

在使用任何企业版功能之前,请确保所有节点均已升级到企业版。