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

Install or Uninstall mongot on Linux

You can install the MongoDB Search and MongoDB Vector Search process, mongot, in MongoDB Community Edition. The mongot process is available for deployment for all Linux distributions such as Red Hat, Ubuntu, Debian, SUSE, and Amazon Linux as a tarball with the .tgz extension.

注意

To onboard quickly with a deployment for experimentation, see the following tutorials for Self-Managed deployments:

To install mongot in a self-managed deployment, you must have the following prerequisites:

  • MongoDB Community Edition v8.2 or later.

    有关安装教程,请参阅安装MongoDB Community Edition

    注意

    You must have a minimum of MongoDB 8.2.0 to run MongoDB Search and MongoDB Vector Search process with a self-managed deployment. For more information, see Compatibility and Requirements for mongot.

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

1

单击以下链接下载社区搜索 tarball。

对于 ARM 架构,请使用 ARM 兼容的 tarball

对于 AMD x86_64 架构,请使用 AMD x86-64 兼容 tarball

2

See Verify Integrity of mongot Packages for more information.

3

运行以下命令以提取 tarball:

tar -zxvf mongot_community_0.53.0_linux_aarch64.tgz
tar -zxvf mongot_community_0.53.0_linux_x86_64.tgz

注意

如果您的网络浏览器在下载过程中自动解压缩该文件,则文件扩展名为 .tar

The tarball contains a sample configuration file, the mongot launcher script, and MongoDB Search and Vector Search license information.

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.

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角色的用户:

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

    • <your-mongot-password> 替换为您在 passwordFile 中指定的密码

    • 运行命令

    db.createUser(
    {
    user: <mongot_username>,
    pwd: <mongot_password>,
    roles: [ "searchCoordinator"]
    }
    )
6

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

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

echo -n "mongotPassword" > 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.

The tarball contains the following sample configuration file, config.default.yml, with the default mongot settings. You can modify the settings for your deployment:

警告

Depending on your system topology, it may be necessary to bind the mongot query server to an interface reachable from your MongoDB Cluster. While binding to the 0.0.0.0 IP address is permitted, it exposes the server to all public networks and carries the risk of unauthorized access.

为了增强安全性,请考虑将 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

注意

The dataPath directory in your configuration file must be writable by the user that runs 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, if the mongot process is running

    mongot might not serve queries as it doesn't check the status of the indexes, which must be in Ready state to serve queries.

  • NOT_SERVING, if the mongot process isn't running

To remove MongoDB Search and MongoDB Vector Search from a system, you must remove mongot, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.

1

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

use admin
db.dropUser("mongotUser")

For details, see db.dropUser().

2

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

3

To remove the mongot and mongod configuration files, run the following commands as root or with sudo by using the full path to your configuration files:

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

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

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

要删除mongot 的日志和日志目录,请使用日志目录的完整路径运行以下命令:

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

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

rm /path/to/mongot/data