使用此页面上的教程来验证 mongot 部署是否处于活动状态并连接到 MongoDB Community 部署。
开始之前
Install MongoDB Community 和 MongoDB Search。有关安装教程,请参阅Install MongoDB Community Edition和步骤。
步骤
验证 mongot 实例的运行状况。
要检查 mongot 实例的健康状态,请使用 /health 和 /ready 终结点。
要检查 mongot 是否处于活动状态,请针对 /health 终结点 curl:
注意
默认 healthCheck 地址为 localhost:8080。但是,您可以在 mongot 配置文件的 healthCheck.address 选项中定义地址。
curl localhost:8080/health
终结点返回以下响应之一:
{"status":"SERVING"}, 如果mongot进程正在运行。{"status":"NOT_SERVING"}, 如果mongot进程未运行。
要检查 mongot 是否可以查询,请针对 /ready 终结点 curl:
curl localhost:8080/ready
终结点返回以下响应之一:
{"status":"SERVING"},如果mongot进程已准备好进行查询。{"status":"NOT_SERVING"}, 如果mongot进程尚未准备好查询。
检查 mongot Prometheus 指标。
如果您在 mongot 配置文件中启用了 Prometheus 指标终结点,curl /metrics 终结点以检索进程级别指标:
curl localhost:9946/metrics
注意
默认 metrics 地址为 localhost:9946。要使用其他地址,请在 mongot 配置文件中设置 metrics.address 选项。
要查看搜索索引复制的状态,请过滤 mongot_replication_mongodb_indexManagerState 指标:
curl -s localhost:9946/metrics | grep -E \ "^(# (HELP|TYPE) mongot_replication_mongodb_indexManagerState|mongot_replication_mongodb_indexManagerState)"
运行搜索查询。
运行端到端搜索查询,以确认完整的查询路径可用。
例如,创建带有搜索索引的 test 集合:
db.test.insertMany([ { name: "alpha" }, { name: "beta" }, { name: "alphabet" } ]) db.test.createSearchIndex( "verify-index", { mappings: { dynamic: true } } )
验证 MongoDB 构建索引:
db.test.getSearchIndexes()
如果命令返回以下响应,则索引可用于查询:
status: 'READY', queryable: true,
然后,运行搜索查询:
db.test.aggregate([ { $search: { index: "verify-index", text: { query: "alpha", path: "name" } } } ])
成功查询确认您正确配置了 mongod 和 mongot。
有关疑难排解 mongot 和 mongod 连接,请参阅自管理部署的 MongoDB Search 疑难排解。