您可以在 MongoDB Community Edition 中安装 MongoDB Search 和 MongoDB 向量搜索进程 mongot。mongot 进程可以作为具有 .tgz 扩展名的 tarball 部署到所有 Linux 发行版,例如 Red Hat、Ubuntu、Debian、SUSE 和 Amazon Linux。
注意
要快速使用用于实验的部署,请参阅以下自管理部署教程:
开始之前
要在自管理部署中安装 mongot,您必须满足以下先决条件:
MongoDB Community Edition v8.2 或更高版本。
有关安装教程,请参阅安装MongoDB Community Edition。
注意
您必须使用 MongoDB 8.2 或更高版本,才能以独立运行的实例自管理部署运行 MongoDB Search 和 MongoDB 向量搜索进程。如果使用 Kubernetes 操作符的 MongoDB 控制器进行部署,则需要 MongoDB 8.3 或更高版本。有关更多信息,请参阅
mongot的兼容性和要求。具有密钥文件访问权限控制的已启动副本集。
步骤
下载 mongot tarball。
单击以下链接下载社区搜索 tarball。
对于 ARM 架构,请使用 ARM 兼容的 tarball。
对于 AMD x86_64 架构,请使用 AMD x86-64 兼容 tarball。
(可选).验证 tarball 包的完整性。
有关详细信息,请参阅验证mongot包的完整性。
配置 mongod 以与 mongot 通信。
如果您有要使用的现有副本集,请配置以下 mongod 参数来路由搜索和MongoDB Vector Search 查询并托管索引。
Parameter | 说明 |
|---|---|
|
|
|
您必须在 |
| 指定是否为搜索索引管理服务器启用身份验证 |
| 指定是否为MongoDB搜索启用 GRPC |
示例,您可以将以下行添加到 mongod 配置文件中,然后重新启动 mongod:
setParameter: searchIndexManagementHostAndPort: localhost:27028 mongotHost: localhost:27028 skipAuthenticationToSearchIndexManagementServer: false useGrpcForSearch: true
有关设置 mongod 参数的更多信息,请参阅自管理部署的 MongoDB Server Parameters。有关搜索特定 setParameter 选项的详细信息,请参阅MongoDB Search 选项。
如果要使用密钥文件身份验证部署新的副本集,请按照部署具有密钥文件身份验证的自管理副本集。中的步骤进行操作。
为 MongoDB 部署上的 mongot进程创建用户。
mongot 必须能够通过具有searchCoordinator角色的用户连接到MongoDB 部署。
以管理员用户身份连接到
mongosh。mongosh --port 27017 -u <your_admin_username> -p <your_admin_password> 连接到
admin数据库。运行以下命令以连接到
admin数据库:use admin 创建
mongot用户。要创建具有
searchCoordinator角色的用户:将
<mongot-username>替换为mongot用户的用户名将
<mongot-password>替换为在下一步中为passwordFile指定的密码运行以下命令:
db.createUser( { user: <mongot-username>, pwd: <mongot-password>, roles: [ "searchCoordinator"] } )
指定 mongot 配置选项。
您可以使用 YAML 配置文件配置 mongot。使用名为 config.default.yml 的附带示例配置文件或新的配置文件来定义配置。有关 mongot 配置选项的更多信息,请参阅 mongot 选项。
该 tarball 包含以下示例配置文件config.default.yml,具有默认的mongot 设置。您可以修改部署的设置:
警告
根据您的系统拓扑结构,可能需要将 mongot 查询服务器绑定到可从 MongoDB 集群访问的接口。虽然允许绑定到 0.0.0.0 IP 地址,但这会将服务器暴露于所有公共网络,并带来未经授权访问的风险。
为了增强安全性,请考虑将 server.grpc.address 限制为在网络层受控制和保护的特定接口,例如 localhost 或其他可信内部地址。
syncSource: replicaSet: hostAndPort: "localhost:27017" # Replace with the mongod host and port. username: mongotUser # Replace with mongod username enabled with "searchCoordinator" role. passwordFile: "/etc/mongot/secrets/passwordFile" # Replace with path to password file for the above user. tls: false storage: dataPath: "/var/lib/mongot" # Replace with the path where you want mongot to store search data. server: grpc: address: "localhost:27028" # Replace with the address and port for mongot listen server tls: mode: "disabled" metrics: enabled: true address: "localhost:9946" healthCheck: address: "localhost:8080" logging: verbosity: INFO
注意
配置文件中的 dataPath 目录必须可由运行 mongot 的用户写入。
使用 logging.logPath 指定 mongot 写入的日志文件的路径。如果您未指定日志文件路径,mongot 将日志记录到标准输出。
验证 mongot 进程的运行状况。
要验证,请使用 HTTP 客户端或 curl 向 /health 终结点发送请求。例如,发送类似以下示例请求的 curl 请求:
curl localhost:8080/health
端点在响应中返回以下内容之一:
SERVING, 如果mongot进程正在运行mongot可能无法提供服务查询,因为它不检查索引的状态,而索引必须处于Ready状态才能提供服务查询。NOT_SERVING,如果mongot进程未运行
有关详细信息,请参阅验证 mongot 连接。
卸载MongoDB Search 和MongoDB Vector Search
要从系统中删除 MongoDB Search 和 MongoDB Vector Search,必须删除 mongot、配置文件以及任何包含数据和日志的目录。以下部分将指导您完成必要步骤。
删除 的所有日志和日志目录 mongot
要删除 mongot 的日志和日志目录,请使用在 logging.logPath 中指定的日志目录的完整路径运行以下命令:
rm -rf /path/to/mongot-logs
后续步骤
创建MongoDB Search 索引