首页 > 其他分享 >Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster reroute API

Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster reroute API

时间:2023-06-24 23:24:00浏览次数:36  
标签:Cluster 精讲 APIs shard allocation cluster API 分片 reroute

REST APIs —— Cluster APIs —— Cluster reroute API

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-reroute.html#cluster-reroute

Changes the allocation of shards in a cluster.

更改集群中分片的分配。

1、Request(请求)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-reroute.html#cluster-reroute-api-request

        POST /_cluster/reroute?metric=none
    

2、Prerequisites(先决条件)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-reroute.html#cluster-reroute-api-prereqs

If the Elasticsearch security features are enabled, you must have the manage cluster privilege to use this API.

如果启用了 Elasticsearch 安全特性,则必须拥有管理集群特权才能使用此 API。

3、Description(描述)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-reroute.html#cluster-reroute-api-desc

The reroute command allows for manual changes to the allocation of individual shards in the cluster. For example, a shard can be moved from one node to another explicitly, an allocation can be cancelled, and an unassigned shard can be explicitly allocated to a specific node.

reroute 命令允许手动更改群集中单个分片的分配。例如,可以显式地将一个分片从一个节点移动到另一个节点,可以取消分配,也可以将未分配的分片显式分配给特定的节点。

It is important to note that after processing any reroute commands Elasticsearch will perform rebalancing as normal (respecting the values of settings such as cluster.routing.rebalance.enable) in order to remain in a balanced state. For example, if the requested allocation includes moving a shard from node1 to node2 then this may cause a shard to be moved from node2 back to node1 to even things out.

需要注意的是,在处理任何 reroute 命令后,Elasticsearch 将像平衡状态一样执行再平衡(尊重 cluster.routing.rebalance.enable 等设置的值)。例如,如果所请求的分配包括将分片从 node1 移动到 node2,则这可能导致从 node2 移动一个分片回到 node1 以平衡状态。

The cluster can be set to disable allocations using the cluster.routing.allocation.enable setting. If allocations are disabled then the only allocations that will be performed are explicit ones given using the reroute command, and consequent allocations due to rebalancing.

集群可以设置为禁用分配,使用 cluster.routing.allocation.enable 设置。如果禁用分配,则执行的唯一分配是使用 reroute 命令给出的显式分配以及由于再平衡而导致的分配。

It is possible to run reroute commands in "dry run" mode by using the ?dry_run URI query parameter, or by passing "dry_run": true in the request body. This will calculate the result of applying the commands to the current cluster state, and return the resulting cluster state after the commands (and re-balancing) has been applied, but will not actually perform the requested changes.

可以通过使用 ?dry_run URI 查询参数或在请求体中传递 "dry_run": true 来以“dry_run”模式运行 reroute 命令。这将在应用命令(和再平衡)之后计算将命令应用于当前集群状态的结果,并返回结果集群状态,但实际上不会执行请求的更改。

If the ?explain URI query parameter is included then a detailed explanation of why the commands could or could not be executed is included in the response.

如果包括 ?explain URI 查询参数,则响应中包括关于为什么可以或无法执行命令的详细说明。

The cluster will attempt to allocate a shard a maximum of index.allocation.max_retries times in a row (defaults to 5), before giving up and leaving the shard unallocated. This scenario can be caused by structural problems such as having an analyzer which refers to a stopwords file which doesn’t exist on all nodes.

集群将尝试将分片分配最多 index.allocation.max_retries 次(默认为 5)连续次数,然后放弃并使分片未分配。这种情况可以由结构性问题引起,例如具有引用不存在于所有节点上的停用词文件的分析器。

Once the problem has been corrected, allocation can be manually retried by calling the reroute API with the ?retry_failed URI query parameter, which will attempt a single retry round for these shards.

一旦问题得到纠正,就可以通过在 reroute API 中调用 ?retry_failed URI 查询参数来手动重试分配这些分片,它将为这些分片尝试一个重试轮。

1、Examples(例子)

https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-reroute.html#cluster-reroute-api-example

This is a short example of a simple reroute API call:

这是一个简单的重路由 API 调用的简短示例:

        curl -X POST "localhost:9200/_cluster/reroute?metric=none&pretty" -H 'Content-Type: application/json' -d'
        {
          "commands": [
            {
              "move": {
                "index": "test", "shard": 0,
                "from_node": "node1", "to_node": "node2"
              }
            },
            {
              "allocate_replica": {
                "index": "test", "shard": 1,
                "node": "node3"
              }
            }
          ]
        }'

标签:Cluster,精讲,APIs,shard,allocation,cluster,API,分片,reroute
From: https://www.cnblogs.com/zuoyang/p/17501861.html

相关文章

  • Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster state API
    RESTAPIs——ClusterAPIs——ClusterstateAPIhttps://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-state.html#cluster-stateReturnsaninternalrepresentationoftheclusterstatefordebuggingordiagnosticpurposes.......
  • Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster health API
    RESTAPIs——ClusterAPIs——ClusterhealthAPIhttps://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-health.html#cluster-healthReturnsthehealthstatusofacluster.返回集群的健康状态。1......
  • Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster get settings
    RESTAPIs——ClusterAPIs——ClustergetsettingsAPIhttps://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-get-settings.html#cluster-get-settingsReturnscluster-widesettings.返回集群的设置。......
  • Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Cluster allocation ex
    RESTAPIs——ClusterAPIs——ClusterallocationexplainAPI(用于提供关于特定分片当前分配情况的解释)https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster-allocation-explain.html#cluster-allocation-explainProvidesanexplanationforashar......
  • Elasticsearch专题精讲—— REST APIs —— Cluster APIs —— Node specification
     RESTAPIs——ClusterAPIs—— Nodespecification(节点过滤)https://www.elastic.co/guide/en/elasticsearch/reference/8.8/cluster.html#cluster-nodes Somecluster-levelAPIsmayoperateonasubsetofthenodeswhichcanbespecifiedw......
  • 什么是 Kubernetes cluster 的 Node affinity
    Nodeaffinity在概念上类似于nodeSelector,它允许您根据节点标签来限制Pod可以调度到哪些节点上。有两种类型的节点亲和性:requiredDuringSchedulingIgnoredDuringExecution:除非满足规则,否则调度程序无法将Pod调度到节点上。这类似于nodeSelector,但具有更具表达性的语法。pre......
  • kube-apiserver认证
    kube-apiserver认证kube-apiserver支持多种认证机制,并支持同时开启多个认证功能。当客户端发起一个请求,经过认证阶段时,只要有一个认证器通过,则认证器成功,失败返回401一共九种认证机制BasicAuth认证BasicAuth是一种简单的HTTP协议上的认证机制,客户端将用户,密码写入请......
  • 8086汇编语言精讲1 :基础知识
    基础知识   也就是说伪指令和其他符号在编译器上将汇编指令翻译成的机械码改动,形成新的机械码      8086可以寻址2^16大小的数据量,因为它有16根数据总线,同时是在2进制下计数         ......
  • API网关-APISIX简介
    本文分享自天翼云开发者社区《API网关-APISIX简介》,作者:w****nApacheAPISIX是一个动态、实时、高性能的云原生API网关,提供了负载均衡、动态上游、灰度发布、服务熔断、身份认证、可观测性等丰富的流量管理功能。APISIX构建于nginx+ngx_lua的技术基础之上,充分利用了LuaJIT所......
  • CF1835C. Twin Clusters
    题目大意给出一个长为\(2^{K+1}\)的序列,每个元素在\([0,4^K)\)之间,在序列中找到两个不相交的区间使得二者的异或和相等\(K<=17,\sum2^{K+1}<=2^{18}\)题解好题,但最后没有break出去绝杀失败了,rk70=>rk150因为元素大小是\(4^K\)级别的,和大小相关的算法(FWT)都没用了,所以不如直接......