ES Cluster Management (Cluster planning, building clusters, cluster management)

A cluster plan

Build a cluster we need to consider the following questions:

1. We need a massive cluster?

2. How the node in the cluster distribution?

3. How to avoid split brain problem?

4. How many slices index should be set?

5. fragmentation should set up a few copies?

Here we have to analyze and answer these questions

1, we need more large-scale clusters?

We need to consider the following two aspects:

1.1 amount of data currently much? How data growth?
1.2 How to configure your machine? cpu, how much RAM, how much hard drive capacity?

Extrapolated based on:

ES JVM heap can set the maximum 32G.
30G heap data amount would be able to process 10 T. If such large memory 128G, ES nodes can run multiple instances on one machine.

Note: The cluster planning to meet current data scale + scale to increase the amount of follow-up may expand as needed.

Two types of scenarios:

A. Construction of a search service function module, and mostly vertical search field. Data on the order of tens of millions to billions of levels. General scale of 2-4 machine.
Real-time OLAP (on-line process analysis) B. for large-scale data, such as the classic ELK Stack, data scale may reach 100 billion or more. The scale of tens to hundreds of nodes.

2, how the role of the node in the cluster distribution?

2.1 Node Role:

Master 
node.master: node as a master node to true
DataNodes
node.data: defaults to true data node. 
Coordinate node  coordinator node
if only as a coordinator node, the two configuration is set to false.

Description:

A node can act as one or more roles, role has three default

The coordinator node: a node receives a request only, forward the request to other nodes, each node summary node data return function. Called the coordinator node

How to allocate 2.2:

A. Small-scale clusters, without strict distinction.
B. in large clusters (more than ten nodes) should be considered a separate act as role. Especially large amount of concurrent queries, merging large queries, can increase the independence of the coordinator node. Role separate benefit is separate from the division of labor, it does not affect each other. Such as the ability to does not affect data nodes due to excessive load coordinating role.

3, how to avoid split brain problem?

3.1 split brain problem :

What a cluster is only one master node A, because A master node need to deal with too much or too busy network, resulting in unreasonable A master node from the other node ping, so that others will think from node A master node is unavailable, and on will re-elect a new primary node B. After A master node back to normal, so that there have been two primary nodes, causes a portion of data from the master node A, the other part of the data from the master node B, the data inconsistency problem, which is split brain .

3.2 to avoid cracking the brain, it is necessary to add the minimum number of primary nodes arranged:

discovery.zen.minimum_master_nodes:  (there are qualified master nodes / 2) + 1

This parameter controls that need to see a minimum number of live nodes with master qualified electing a master node, in order to carry out the elections. The official recommended value is (N / 2) +1, where N is the number of nodes having a master qualification.

3.3 The common practice (in large clusters):

1. Master role and dataNode separate master configuration odd number, such as 3 
2. unicast discovery mechanism configured master node qualifications:

discovery.zen.ping.multicast.enabled: false - Close multicast discovery mechanism is off by default

discovery.zen.ping.unicast.hosts: [ "master1", "master2", "master3"] - the master node ip address configuration unicast discovery from other nodes to join, you have to ask Unicast discovery mechanism the master node configuration inside I want to join the cluster inside, and later agreed to join the master node, then the master node then notify the other nodes in the cluster have a new node is added

3. Configure the number of electoral found and wait for an extended length of ping master

discovery.zen.ping_timeout: 30 (default is 3 seconds) - ping other nodes in the master node does not respond to think how long time the master node becomes unavailable
discovery.zen.minimum_master_nodes: 2 - need to see the minimum number of electing a master node a live node has a master's qualifications to carry out elections

4, index of how many slices should be set?

Description: Specifies the number of fragments immutable, unless the weight index.

Thinking:

What fragment corresponding to the storage entity is?

  The index is stored entity

Fragmentation is not better?

  No

Multi-slice have any effect?

  Fragment more than a waste of storage space, footprint, impact performance

4.1 slices too much influence:

It is essentially a Lucene index each slice, and therefore will consume the appropriate file handles, memory, and CPU resources.
Each search request is dispatched to the index for each slice. If the slices are dispersed in different nodes touches problem is not, but when the start competing for the same hardware resources fragment, performance will gradually decline.
ES to calculate the correlation between the use of word frequency statistics. Of course, these statistics will be assigned to each slice. If on a large slice maintains only a small amount of data, it will result in a final document poor correlation.

4.2 Reference may be disposed fragmentation principles:

ElasticSearch recommended maximum JVM heap space is 30 ~ 32G, so take your slice maximum capacity is limited to 30GB, then the number of slices to make a reasonable estimate. For example, do you think your data can reach 200GB, recommend a maximum of distribution 7 to 8 slices.
At the beginning, a good solution is based on your number of nodes in the 1.5 to 3 times the principle of creating slices. For example, if you have three nodes, the number of slices is recommended that you create a maximum of 9 (3x3) a. When performance degradation, increased node, ES balances slice is placed.
For an index based on the date of the demand, and the index data search scene is very small. Perhaps these indexes will reach hundreds of thousands, but the amount of data for each index only 1GB even smaller. For this similar scene, it is recommended only 1 slice allocated for the index. Such as log management is an index needs a date, the date the index will be a lot, but the amount of log data stored in each index rarely.

5, fragmentation should set a few copies?

Description: The number of copies can be adjusted at any time!

Thinking:

What use is a copy?

  Backup data to ensure high availability of data is not lost, when involved in highly concurrent data query
for its use, how do we set the number of copies of it?

  There is generally a slice or two copies of highly available to ensure
a copy of the case there will be too many cluster size has not changed any effect?

  Copy more than a waste of storage space, footprint, impact performance

5.1 replica sets basic principles:

To ensure high availability, the number of copies can be set to 2. Minimum of 3 required cluster node to store the main fragments, a copy of separately.
Such as found in concurrent capacity, query performance will decline, increase the number of copies, to enhance the ability of concurrent queries.

Note: When the master node will automatically coordinate the new copy, and then copies the data to the new copy of the node

Second, the Cluster Setup

1. Prepare 3 virtual machine:

192.168.152.128 、192.168.152.129、192.168.152.130

2. 3 virtual machines are installed inside elasticsearch

Installation Guide refer to my article before writing ES installation and configuration sections:

https://www.cnblogs.com/leeSmall/p/9189078.html

3. Modify the ES virtual machine configuration at 3, so that they form a cluster

Elasticsearch into the config directory, modify the configuration of elasticsearch.yml

3.1. IP access restrictions, modify the default port 9200

There are two need to be reminded, the first is the IP access restrictions, and the second is the default port number 9200 es instance. IP access restrictions may define a specific IP access server, which has a certain safety filtration.

# Set the bind address to a specific IP (IPv4 or IPv6): 
# 
network.host: 192.168.152.128

If set to 0.0.0.0 is not limited to any IP access. In general the production server may define several IP, commonly used for management.

The default port 9200 in general is also a bit of risk, the default port can be modified to another, there is a reason this is the fear of misuse developers, connected on the cluster. Of course, if your company network isolation doing well it does not matter.

# 
# Set a custom port for HTTP: 
# 
http.port: 9200 
transport.tcp.port: 9300

9300 Here is a cluster internal communications port used, this can also be modified out. Because there are two ways to connect to the cluster by cluster node also may play into the cluster, so it is still safe, off to modify the default port.

Note: Remember to modify the ES 3 virtual machines (three nodes) of the same configuration installation, you can not establish a connection between the work or else node will error.

3.2 clusters found IP list, node, cluster name

Then modify the cluster node IP addresses, which would allow cluster nodes to work between several provisions. elasticsearch, the default is to use the IP auto-discovery mechanism. That is, in the current network segment, as long as can be automatically perceived IP can be automatically added to the cluster. This is good and bad. Benefit is automated, when you need cloud cluster es of the time will be very convenient. But it will also bring some instability, such as the election of the master, data replication problem.

One of the factors leading to the election is the master node into the cluster there. When the data replication occurs also affects the cluster, because to do balance data replication and redundancy. There may be a separate master cluster, remove master node cluster of data capacity.

A fixed list of IP configuration found in two ways, one is interdependent found that a total amount was found. Have their own advantages, and I used to do is rely on the discovery. It has a very important reference standard, that is how quickly your cluster expansion rate. This is because there is a problem is that when the full amount found, if it is to initialize the cluster will be a great problem is the global master will be very long, and then start speed between nodes not the same. So I used the dependence fly point found.

You need to be configured to 192.168.152.128 in the elasticsearch in:

# --------------------------------- Discovery ---------------------------------- 
# 
# Pass an initial list of hosts to perform discovery when new node is started: 
# The default list of hosts is ["127.0.0.1", "[::1]"] 
# 
discovery.zen.ping.unicast.hosts: [ "192.168.152.129:9300","192.168.152.130:9300" ]

Let him go to find 129,130 ​​of the machine, in order to push inside, complete the configuration of the rest of the 129 and 130 machines.

Then you need the name of the cluster configuration, where is your current node name of the cluster, which helps you plan your cluster. The names of all cluster nodes in the cluster must be the same as the name of the cluster can only form a logical cluster.

# ---------------------------------- Cluster ----------------------------------- 
# 
# Use a descriptive name for your cluster: 
# 
cluster.name: mycluster 

Configure the name of your current node

# 
# ------------------------------------ Node ------------------------------------ 
# 
# Use a descriptive name for the node: 
# 
node.name: node-1

By analogy, the other two nodes to complete the configuration. cluster.name name must remain the same. And then were set node.name.

Description:

Here is a simple to build clusters, cluster nodes do not distinguish between the role, so the three nodes default roles have master node, data node, the coordinator node

Election ES master node logic:

Probably logic election, it will be based freshness slice data before and after as an important logical elections. (Log data, the time will be used as an important indicator of global cluster master)

Considering that the data consistency problem, of course, with the latest data node as a master, and then copy and refresh the other node of the new data.

Third, cluster management

1. Monitoring API

http://localhost:9200/_cat

GET  /_cat

/_cat/health
/_cat/nodes
/_cat/master
/_cat/indices
/_cat/allocation 
/_cat/shards 
/_cat/shards/{index}
/_cat/thread_pool
/_cat/segments 
/_cat/segments/{index}

2. x-pack

To provide security for the cluster, monitoring, alerting, reporting and other functions charged components;
partially free: HTTPS: //www.elastic.co/subscriptions
6.3 start has been open source, and incorporates elasticsearch core.

Official website installation instructions:

https://www.elastic.co/guide/en/elasticsearch/reference/6.2/installing-xpack-es.html

 

Reference article:

Build a cluster: https: //www.cnblogs.com/wangiqngpei557/p/5967377.html

Cluster Setup two: https: //www.cnblogs.com/jstarseven/p/6803054.html this article written in more detail, and also summarizes the problems encountered in the process of building, building cluster, then strongly recommended ES

Guess you like

Origin www.cnblogs.com/ExMan/p/11328594.html