Elastīgā meklēšana

Elasticsearch Shard Rebalancing Tutorial

Elasticsearch Shard Rebalancing Tutorial
An Elasticsearch shard is a unit that allows the Elasticsearch engine to distribute data in a cluster. In Elasticsearch, we say that a cluster is “balanced” when it contains an equal number of shards on every node without having a large concentration of shards on a single node. Depending on how you configure Elasticsearch, it automatically performs shards rebalancing in your cluster to improve performance.

Automatic shard rebalancing conforms to restrictions and rules like allocation filtering and forced awareness, leading to the most efficient and well-balanced cluster possible.

NOTE: Do not confuse shard reallocation, which is the process of finding and moving unassigned shards to the nodes in which they reside, with rebalancing. Rebalancing takes assigned shards and moves them evenly to various nodes, the purpose being the equal distribution of shards per node.

How to Enable Automatic Rebalancing

To enable automatic cluster rebalancing in Elasticsearch, we can use the PUT request to_cluster API endpoint and add the settings we need.

The settings available for dynamic shard rebalancing include:

Consider the request below to allow automatic shard rebalancing for the cluster.

PUT /_cluster/settings

"persistent":
"cluster.routing.rebalance.enable": "primaries",
"cluster.routing.allocation.allow_rebalance": "always" ,
"cluster.routing.allocation.cluster_concurrent_rebalance":"2"

The following is the cURL command:

curl -XPUT "http://localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'   "persistent": "cluster.routing.rebalance.enable": "primaries","cluster.routing.allocation.allow_rebalance":  "always"      ,"cluster.routing.allocation.cluster_concurrent_rebalance":"2"    '

This command should return a response as the JSON object acknowledges the settings that are updated.


“acknowledged”: true,
"persistent" :
"cluster" :
"routing" :
"rebalance" :
"enable" : "primaries"
,
"allocation" :
"allow_rebalance" : "always",
"cluster_concurrent_rebalance" : "2"



,
"transient" :

Manual Index Rebalancing

You can also rebalance a shard manually for a specific index. I would not recommend this option because the Elasticsearch default rebalancing options are very efficient.

However, should the need to perform manual rebalancing arise, you can use the following request:


“acknowledged”: true,
"persistent" :
"cluster" :
"routing" :
"rebalance" :
"enable" : "primaries"
,
"allocation" :
"allow_rebalance" : "always",
"cluster_concurrent_rebalance" : "2"



,
"transient" :

The cURL command is:

curl -XPOST "http://localhost:9200/_cluster/reroute" -H 'Content-Type: application/json' -d'    "commands" : [                    "move" :                 "index" : "kibana_sample_data_flights", "shard" : 0,                "from_node" : "instance-0000000001", "to_node" : "instance-0000000002"                        ]'

NOTE: Keep in mind that if you perform a manual rebalance, Elasticsearch may move the shards automatically to ensure the best rebalance possible.

Conclusion

This guide walked you through updating and modifying the settings for an Elasticsearch cluster to enable automatic shard rebalancing. The article also covered manual rebalancing, if you require it.

Rakstot Windows 10, kursors lec vai pārvietojas nejauši
Ja atklājat, ka peles kursors automātiski, nejauši lec vai pārvietojas pats, rakstot Windows klēpjdatorā vai datorā, daži no šiem ieteikumiem var palī...
Kā mainīt peles un skārienpaliktņu ritināšanas virzienu operētājsistēmā Windows 10
Pele un SkārienpaliktnisTas ne tikai padara skaitļošanu vienkāršu, bet arī efektīvāku un mazāk laikietilpīgu. Mēs nevaram iedomāties dzīvi bez šīm ier...
Kā mainīt peles rādītāja un kursora izmēru, krāsu un shēmu operētājsistēmā Windows 10
Peles rādītājs un kursors operētājsistēmā Windows 10 ir ļoti svarīgi operētājsistēmas aspekti. To var teikt arī par citām operētājsistēmām, tāpēc pati...