您可以在 MongoDB Community Edition 中安装 MongoDB Search 和 MongoDB 向量搜索进程 mongot。mongot 进程可以作为具有 .tgz 扩展名的 tarball 部署到所有 Linux 发行版,例如 Red Hat、Ubuntu、Debian、SUSE 和 Amazon Linux。
注意
要快速使用用于实验的部署,请参阅以下自管理部署教程:
开始之前
要在自管理部署中安装 mongot,您必须满足以下先决条件:
MongoDB Community Edition v8.3 或更高版本。
See Install MongoDB Community Edition for installation tutorials.
注意
You must have MongoDB 8.3 or later to run MongoDB Search and MongoDB Vector Search process, whether you use a standalone self-managed deployment or deploy with the MongoDB Controllers for Kubernetes Operator. For more information, see Compatibility and Requirements for
mongot.具有密钥文件访问权限控制的已启动副本集。
步骤
Download the mongot tarball.
Download the latest Search in Community tarball for your system architecture from the MongoDB Search in Community Download Center.
To download a specific version from the command line, replace {VERSION_NUMBER} with the version of mongot that you want and run the command for your system architecture:
wget https://downloads.mongodb.org/mongodb-search-community/{VERSION_NUMBER}/mongot_community_{VERSION_NUMBER}_linux_aarch64.tgz
wget https://downloads.mongodb.org/mongodb-search-community/{VERSION_NUMBER}/mongot_community_{VERSION_NUMBER}_linux_x86_64.tgz
(可选).验证 tarball 包的完整性。
有关详细信息,请参阅验证mongot包的完整性。
Extract the mongot tarball.
Replace {VERSION_NUMBER} with the version of mongot that you downloaded and run the command for your system architecture to extract the tarball:
tar -zxvf mongot_community_{VERSION_NUMBER}_linux_aarch64.tgz
tar -zxvf mongot_community_{VERSION_NUMBER}_linux_x86_64.tgz
注意
如果您的网络浏览器在下载过程中自动解压缩该文件,则文件扩展名为 .tar。
该 tarball 包含一个示例配置文件、mongot 启动程序脚本以及 MongoDB Search 和向量搜索许可证信息。
Configure mongod to communicate with mongot.
如果您有要使用的现有副本集,请配置以下 mongod 参数来路由搜索和MongoDB Vector Search 查询并托管索引。
Parameter | 说明 |
|---|---|
|
|
|
您必须在 |
| 指定是否为搜索索引管理服务器启用身份验证 |
| 指定是否为MongoDB搜索启用 GRPC |
示例,您可以将以下行添加到 mongod 配置文件中,然后重新启动 mongod:
setParameter: searchIndexManagementHostAndPort: localhost:27028 mongotHost: localhost:27028 skipAuthenticationToSearchIndexManagementServer: false useGrpcForSearch: true
See MongoDB Server Parameters for a Self-Managed Deployment for more information on setting mongod parameters. For detailed information about search-specific setParameter options, see MongoDB Search Options.
注意
The mongotHost, searchIndexManagementHostAndPort, and useGrpcForSearch parameters are set only at startup. You can't change them at runtime with setParameter. To point mongod at a different mongot instance, update these parameters in the mongod configuration file and restart mongod.
If you want to deploy a new replica set with keyfile authentication, follow the steps in Deploy Self-Managed Replica Set With Keyfile Authentication.
Create a user for the mongot process on your MongoDB deployment.
mongot must be able to connect to your MongoDB deployment through a user with the searchCoordinator role.
以管理员用户身份连接到
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 配置选项。
You can configure mongot with a YAML configuration file. Use the included sample configuration file named config.default.yml or a new configuration file to define the configuration. For more information on mongot configuration options, see mongot Options.
该 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. scramAuth: username: mongotUser # Replace with mongod username enabled with "searchCoordinator" role. authSource: admin # Replace with the database to authenticate the user against. passwordFile: "/etc/mongot/secrets/passwordFile" # Replace with path to password file for the above user. tls: enabled: 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 的用户写入。
The sample configuration uses SCRAM authentication with the scramAuth block. You must configure exactly one authentication mechanism for the sync source: either SCRAM or X.509. To authenticate with a TLS client certificate instead of a username and password, use the x509 block. For both mechanisms, including the sharded-cluster syncSource.router configuration, see Configure Authentication and Authorization for mongot.
This sample runs mongot and mongod on the same host, so it binds server.grpc.address to localhost and disables TLS. If you run mongot and mongod on separate hosts, complete the following steps instead:
Bind
server.grpc.addressto a network interface thatmongodcan reach, rather thanlocalhost.Set the
mongodmongotHostandsearchIndexManagementHostAndPortparameters to that address.Enable TLS for the sync source and gRPC connections. Running without TLS is only appropriate when
mongotandmongodrun on the same host. To configure TLS, see Configure TLS Encryption formongot.
使用 logging.logPath 指定 mongot 写入的日志文件的路径。如果您未指定日志文件路径,mongot 将日志记录到标准输出。
Verify the health of the mongot process.
To verify, send a request by using a HTTP client or curl to the /health endpoint. For example, send a curl request similar to the following sample request:
curl localhost:8080/health
端点在响应中返回以下内容之一:
SERVING, 如果mongot进程正在运行mongot可能无法提供服务查询,因为它不检查索引的状态,而索引必须处于Ready状态才能提供服务查询。NOT_SERVING,如果mongot进程未运行
有关详细信息,请参阅验证 mongot 连接。
卸载MongoDB Search 和MongoDB Vector Search
要从系统中删除 MongoDB Search 和 MongoDB Vector Search,必须删除 mongot、配置文件以及任何包含数据和日志的目录。以下部分将指导您完成必要步骤。
Drop the mongotUser user
要删除 mongotUser 用户,运行以下命令:
use admin db.dropUser("mongotUser")
For details, see db.dropUser().
删除 的所有日志和日志目录 mongot
要删除 mongot 的日志和日志目录,请使用在 logging.logPath 中指定的日志目录的完整路径运行以下命令:
rm -rf /path/to/mongot-logs
后续步骤
创建MongoDB Search 索引