Elasticsearch technical analysis and real --shard & replica mechanism

Preface

1, shard & replica mechanism

  (1) index comprising a plurality of shard

  Capacity (2) for each shard is a minimum unit of work, carrying part of the data, Lucene instance, the complete indexing process requests and

  (3) changes in a node, shard automatically load balancing nodes in

  (4) primary shard and replica shard, each document must exist only a certain primary shard and its corresponding replica shard in, can not exist in a plurality of primary shard

  (5) replica shard is the primary shard copy, responsible for fault tolerance, load and bear a read request

  (6) the number of primary shard at the time of creating an index on a fixed number of replica shard can be modified at any time

  (7) a default primary shard number is 5, replica is 1 by default, default 10 has shard, 5 th primary shard, 5 th replica shard

  (8) primary shard and its replica shard can not be placed on the same node (or node goes down, primary shard and replica are lost, would not achieve the role of fault-tolerant), but other primary shard of replica shard in the same a node

2, create a single-node environment index

  (1) single-node environment, create an index, there are three primary shard, three Shard Replica
  (2) cluster status is Yellow
  (3) this time, only the three primary shard is assigned to only one node up other three replica shard is not allocated
  (4) clusters may work, but once the node goes down occurs, data is lost, but the cluster is unavailable, not receiving any request

PUT /test_index
{
   "settings" : {
      "number_of_shards" : 3,
      "number_of_replicas" : 1
   }
}

3、2个node环境下replica shard是如何分配的

  (1)replica shard分配:3个primary shard,3个replica shard,1 node

  (2)primary ---> replica同步

  (3)读请求:primary/replica

Guess you like

Origin www.cnblogs.com/liugp/p/11374725.html