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

Install or Uninstall mongot on Linux

您可以在 MongoDB Community Edition 中安装 MongoDB Search 和 MongoDB 向量搜索进程 mongotmongot 进程可以作为具有 .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.

  • 具有密钥文件访问权限控制的已启动副本集。

1

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
2

有关详细信息,请参阅验证mongot包的完整性

3

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 和向量搜索许可证信息。

4

如果您有要使用的现有副本集,请配置以下 mongod 参数来路由搜索和MongoDB Vector Search 查询并托管索引。

Parameter
说明

searchIndexManagementHostAndPort

mongot 的托管解决。

mongotHost

mongot 的托管解决。

您必须在 searchIndexManagementHostAndPortmongotHost 中指定相同的解决。

skipAuthenticationToSearchIndexManagementServer

指定是否为搜索索引管理服务器启用身份验证

useGrpcForSearch

指定是否为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.

5

mongot must be able to connect to your MongoDB deployment through a user with the searchCoordinator role.

  1. 以管理员用户身份连接到 mongosh

    mongosh --port 27017 -u <your_admin_username> -p <your_admin_password>
  2. 连接到 admin 数据库。

    运行以下命令以连接到 admin数据库:

    use admin
  3. 创建 mongot 用户。

    要创建具有 searchCoordinator角色的用户:

    • <mongot-username> 替换为 mongot 用户的用户名

    • <mongot-password> 替换为在下一步中为 passwordFile 指定的密码

    • 运行以下命令:

    db.createUser(
    {
    user: <mongot-username>,
    pwd: <mongot-password>,
    roles: [ "searchCoordinator"]
    }
    )
6

mongot 创建密码文件,以连接到 mongod

示例,选择您的操作系统并将 <mongot-password> 替换为您的密码。然后运行以下命令,创建名为 passwordFile 的文件:

echo -n "<mongot-password>" > passwordFile
chmod 400 passwordFile

注意

-n 标志可防止出现尾随换行符。

echo|set /p="mongotPassword" > passwordFile
[System.IO.File]::WriteAllText("passwordFile", "mongotPassword")
7

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.address to a network interface that mongod can reach, rather than localhost.

  • Set the mongod mongotHost and searchIndexManagementHostAndPort parameters to that address.

  • Enable TLS for the sync source and gRPC connections. Running without TLS is only appropriate when mongot and mongod run on the same host. To configure TLS, see Configure TLS Encryption for mongot.

使用 logging.logPath 指定 mongot 写入的日志文件的路径。如果您未指定日志文件路径,mongot 将日志记录到标准输出。

8

运行随 Tarball 下载的 mongot 启动器脚本。该脚本位于 mongot-community 文件夹中。

更改为 mongot-community 文件夹:

cd <path-to-mongot>

要使用示例配置文件启动 mongot,请发出以下命令:

./mongot --config config.default.yml
9

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,必须删除 mongot、配置文件以及任何包含数据和日志的目录。以下部分将指导您完成必要步骤。

1

要删除 mongotUser 用户,运行以下命令:

use admin
db.dropUser("mongotUser")

For details, see db.dropUser().

2

要停止 mongot 二进制文件,请在运行该二进制文件的终端会话中使用 Ctrl + C

3

要删除 mongotmongod 配置文件,请以 root 身份运行以下命令,或使用 sudo 并使用配置文件的完整路径:

sudo rm /path/to/config.default.yml
sudo rm /path/to/mongod.conf
4

要删除密钥文件和密码文件,请使用密钥文件和密码文件的完整路径运行以下命令:

rm /path/to/keyfile
rm /path/to/passwordFile
5

要删除 mongot 的日志和日志目录,请使用在 logging.logPath 中指定的日志目录的完整路径运行以下命令:

rm -rf /path/to/mongot-logs
6

要删除存储 mongot 数据的数据目录,请使用 mongot数据目录的完整路径运行以下命令:

rm /path/to/mongot/data