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

通过稳定路径访问 MongoDB 二进制文件

The MongoDB Agent downloads MongoDB Server, mongosh, and MongoDB Database Tools binaries into version-specific directories under the download directory. The default download directory is /var/lib/mongodb-mms-automation. Version-specific paths change each time the agent downloads a new version.

为了提供通往这些二进制文件的稳定路径,代理程序在下载目录中维护以下符号链接:

符号链接名称
目标目录
符号链接路径

mongodb

The bin directory of the highest MongoDB Server version installed on the host

/var/lib/mongodb-mms-automation/mongodb

mongosh

The bin directory of the MongoDB Shell version that Ops Manager manages

/var/lib/mongodb-mms-automation/mongosh

mongodb-tools

The bin directory of the MongoDB Database Tools version that Ops Manager manages

/var/lib/mongodb-mms-automation/mongodb-tools

The examples use the default download directory on Linux and macOS: /var/lib/mongodb-mms-automation. On Windows, the default download directory is C:\MMSAutomation\versions. For example, call mongosh through C:\MMSAutomation\versions\mongosh. If you use a different download directory, change the path prefix to match.

这些符号链接指向下载目录下的特定版本目录。这些目录遵循以下命名模式:

  • MongoDB Server: mongodb-<platform>-<arch>-<version>, for example mongodb-linux-x86_64-7.0.14-ent

  • MongoDB Shell: mongosh-<platform>-<arch>-<version>, for example mongosh-linux-x86_64-2.2.4

  • MongoDB Database Tools: mongodb-database-tools-<platform>-<arch>-<version>, for example mongodb-database-tools-linux-x86_64-100.10.0

代理会自动管理符号链接。您无需自行创建或更新它们。

  • 当代理下载组件的新版本时,它会更新该组件的符号链接,使其指向新版本。此更新适用于升级和降级。

  • The mongodb symlink points to the highest MongoDB Server version installed on the host. When the agent removes the highest version, the symlink points to the highest version that remains.

  • 代理程序会定期检查符号链接。如果符号链接缺失或指向错误的目录,代理程序会重新创建它。只有当所有已配置的符号链接都有效时,符号链接集才是正确的。

  • 如果符号链接的路径中存在文件或空目录,代理程序会将其替换为符号链接。

  • 功能兼容性版本变更不会影响符号链接。

Earlier agent versions maintained a single symlink named bin in the download directory. It pointed to the bin directory of the MongoDB Shell version that Ops Manager manages. Starting with MongoDB Agent 108.0.29.9148-1 and 109.0.3.9449-1, which ship with Ops Manager 8.0.29 and 9.0.3, the agent maintains the stable symlinks instead.

重要

The agent no longer creates or updates the bin symlink. An existing bin symlink remains in place, but after a MongoDB Shell upgrade it can point to an older version or to a version that the agent removed. Update your scripts to use the new stable symlinks.

If your scripts call MongoDB binaries through version-specific paths or through the legacy bin symlink, update them one time to use the stable symlinks. After this change, the scripts continue to work through upgrades and downgrades.

1

Search your scripts for references to the bin symlink or to a version-specific directory under the download directory.

2

以下示例展示了修改前后的脚本:

#!/bin/bashMMS=/var/lib/mongodb-mms-automation # Uses the bin symlink, which the agent# no longer updates$MMS/bin/mongosh "$MONGODB_URI" \ --eval 'db.adminCommand({ ping: 1 })' # Uses version-specific paths, which break# when Ops Manager upgrades the version$MMS/mongodb-database-tools-linux-x86_64-100.20.1/bin/mongodump \ --uri "$MONGODB_URI" \ --out "/backups/$(date +%F)"$MMS/mongodb-linux-x86_64-9.0.7-ent/bin/mongod \ --version

更改后,同一脚本将使用稳定的符号链接:

#!/bin/bashMMS=/var/lib/mongodb-mms-automation $MMS/mongosh/mongosh "$MONGODB_URI" \ --eval 'db.adminCommand({ ping: 1 })'$MMS/mongodb-tools/mongodump \ --uri "$MONGODB_URI" --out "/backups/$(date +%F)"$MMS/mongodb/mongod --version

The mongodb symlink points to the highest MongoDB Server version installed on the host, which might not be the version your script requires. To call a specific version, use that version's directory under the download directory.

如果升级后脚本或部署失败,请检查下载目录中符号链接的状态。

症状
可能的原因
解决方案

Ops Manager 未完成对部署的更改应用,代理日志显示创建符号链接时出错。

下载目录中存在一个与符号链接同名的非空目录。

移动或删除该目录。然后,代理程序会创建符号链接。

The mongosh or mongodb-tools symlink is missing

Ops Manager 不管理主机上的该组件

无。请改用本地安装路径。

要更改下载目录,请参阅“配置部署以限制 Internet 访问”。