关闭(Shutdown)

class elasticsearch.client.ShutdownClient

To use this client, access client.shutdown from an Elasticsearch client. For example:

from elasticsearch import Elasticsearch

# Create the client instance
client = Elasticsearch(...)
# Use the shutdown client
client.shutdown.<method>(...)
delete_node(*, node_id, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, timeout=None)

取消节点关闭准备工作。

将节点从关闭列表中移除,使其恢复正常运行。

当节点重新加入集群或永久离开集群时,必须显式清除关闭请求。

Elasticsearch 永远不会自动移除关闭请求。

注意:此功能专为 Elastic Cloud、Elastic Cloud Enterprise 和 Kubernetes 上的 Elastic Cloud 间接使用而设计。

不支持直接使用。

如果启用了操作员权限功能,您必须是操作员才能使用此 API。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-shutdown-delete-node

Parameters:
  • node_id (str) – 要从关闭状态中移除的节点 ID

  • master_timeout (str | Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's'] | None) – 等待连接主节点的时间。如果在超时前未收到响应,请求将失败并返回错误。

  • timeout (str | Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's'] | None) – 等待响应的时间。如果在超时前未收到响应,请求将失败并返回错误。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

get_node(*, node_id=None, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None)

获取关闭状态。

获取关于准备关闭、关闭准备仍在进行中或已停滞的节点信息。

API 返回关闭过程每个部分的状态信息。

注意:此功能专为 Elasticsearch Service、Elastic Cloud Enterprise 和 Kubernetes 上的 Elastic Cloud 间接使用而设计。不支持直接使用。

如果启用了操作员权限功能,您必须是操作员才能使用此 API。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-shutdown-get-node

Parameters:
  • node_id (str | Sequence[str] | None) – 要检索关闭状态的节点

  • master_timeout (str | Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's'] | None) – 等待连接主节点的时间。如果在超时前未收到响应,请求将失败并返回错误。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

Return type:

ObjectApiResponse[Any]

put_node(*, node_id, reason=None, type=None, allocation_delay=None, error_trace=None, filter_path=None, human=None, master_timeout=None, pretty=None, target_node_name=None, timeout=None, body=None)

准备关闭节点。

注意:此功能专为 Elastic Cloud、Elastic Cloud Enterprise 和 Kubernetes 上的 Elastic Cloud 间接使用而设计。不支持直接使用。

如果指定离线节点,它将在重新加入集群时准备关闭。

如果启用了操作员权限功能,您必须是操作员才能使用此 API。

API 会根据需要将正在进行的任务和索引分片迁移到其他节点,以准备重启或关闭并从集群中移除节点。

这确保可以安全停止 Elasticsearch,同时将对集群的干扰降至最低。

必须指定关闭类型:restartremovereplace

如果节点已在准备关闭,可以使用此 API 更改关闭类型。

重要:此 API 不会终止 Elasticsearch 进程。

监控节点关闭状态以确定何时可以安全停止 Elasticsearch。

https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-shutdown-put-node

Parameters:
  • node_id (str) – 节点标识符。此参数不会针对集群的活动节点进行验证。这使您可以在节点离线时注册关闭。如果指定无效节点 ID 不会抛出错误。

  • reason (str | None) – 节点关闭的人工可读原因。此字段为其他集群操作员提供信息;不影响关闭过程。

  • type (str | Literal['remove', 'replace', 'restart'] | None) – 有效值为 restart、remove 或 replace。当需要临时关闭节点以执行升级、更改配置或执行其他维护时使用 restart。因为节点预期会重新加入集群,数据不会从节点迁移。当需要从集群永久移除节点时使用 remove。在数据从节点迁移完成前,节点不会被标记为准备关闭。使用 replace 进行节点 1:1 替换。某些分配决策(如磁盘水位线)将被忽略,以实现源节点与目标节点的真正替换。在 replace 类型关闭期间,滚动更新和索引创建可能导致未分配的分片,在替换完成前收缩可能失败。

  • allocation_delay (str | None) – 仅在类型为 restart 时有效。控制 Elasticsearch 在将分片重新分配给其他节点前等待节点重启并加入集群的时间。其工作方式与 index.unassigned.node_left.delayed_timeout 设置的延迟分配相同。如果同时指定重启分配延迟和索引级分配延迟,则使用两者中较长的时间。

  • master_timeout (str | Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's'] | None) – 等待连接主节点的时间。如果在超时前未收到响应,请求将失败并返回错误。

  • target_node_name (str | None) – 仅在类型为 replace 时有效。指定替换要关闭节点的节点名称。关闭节点的分片只允许分配给目标节点,其他数据不会分配给目标节点。在数据重新定位期间,某些分配规则(如磁盘水位线或用户属性过滤规则)将被忽略。

  • timeout (str | Literal['d', 'h', 'm', 'micros', 'ms', 'nanos', 's'] | None) – 等待响应的时间。如果在超时前未收到响应,请求将失败并返回错误。

  • error_trace (bool | None)

  • filter_path (str | Sequence[str] | None)

  • human (bool | None)

  • pretty (bool | None)

  • body (Dict[str, Any] | None)

Return type:

ObjectApiResponse[Any]