获取关闭 API

编辑

此功能设计为由 Elasticsearch ServiceElastic Cloud EnterpriseElastic Cloud on Kubernetes 间接使用。不支持直接使用。

检索正在准备关闭的节点的状态。

请求

编辑

GET _nodes/shutdown

GET _nodes/<node-id>/shutdown

先决条件

编辑
  • 如果启用了 Elasticsearch 安全功能,您必须具有 manage 集群权限 才能使用此 API。
  • 如果启用了 操作员权限功能,您必须是操作员才能使用此 API。

描述

编辑

指示节点是否已准备好关闭,或者关闭准备工作是否仍在进行中或已停滞。返回关闭过程每个部分的状态信息。在调用 放置关闭 后,使用此 API 监控关闭过程。

路径参数

编辑
<node-id>
(可选,字符串)正在准备关闭的节点的 ID。如果未指定 ID,则返回正在准备关闭的所有节点的状态。

示例

编辑

准备重启节点

resp = client.shutdown.put_node(
    node_id="USpTGYaBSIKbgSUJR2Z9lg",
    type="restart",
    reason="Demonstrating how the node shutdown API works",
    allocation_delay="10m",
)
print(resp)
response = client.shutdown.put_node(
  node_id: 'USpTGYaBSIKbgSUJR2Z9lg',
  body: {
    type: 'restart',
    reason: 'Demonstrating how the node shutdown API works',
    allocation_delay: '10m'
  }
)
puts response
const response = await client.shutdown.putNode({
  node_id: "USpTGYaBSIKbgSUJR2Z9lg",
  type: "restart",
  reason: "Demonstrating how the node shutdown API works",
  allocation_delay: "10m",
});
console.log(response);
PUT /_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown
{
  "type": "restart",
  "reason": "Demonstrating how the node shutdown API works",
  "allocation_delay": "10m"
}

获取关闭准备工作的状态

resp = client.shutdown.get_node(
    node_id="USpTGYaBSIKbgSUJR2Z9lg",
)
print(resp)
response = client.shutdown.get_node(
  node_id: 'USpTGYaBSIKbgSUJR2Z9lg'
)
puts response
const response = await client.shutdown.getNode({
  node_id: "USpTGYaBSIKbgSUJR2Z9lg",
});
console.log(response);
GET /_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown

响应显示有关关闭准备工作的信息,包括分片迁移、任务迁移和插件清理的状态。

{
    "nodes": [
        {
            "node_id": "USpTGYaBSIKbgSUJR2Z9lg",
            "type": "RESTART",
            "reason": "Demonstrating how the node shutdown API works",
            "shutdown_startedmillis": 1624406108685,
            "allocation_delay": "10m",
            "status": "COMPLETE",
            "shard_migration": {
                "status": "COMPLETE",
                "shard_migrations_remaining": 0,
                "explanation": "no shard relocation is necessary for a node restart"
            },
            "persistent_tasks": {
                "status": "COMPLETE"
            },
            "plugins": {
                "status": "COMPLETE"
            }
        }
    ]
}