Elasticsearch Windows cluster setup

1. Related concepts

1. Single machine & cluster

  • When a single Elasticsearch server provides services, it often has the maximum load capacity. If it exceeds this threshold, the server performance will be greatly reduced or even unavailable. Therefore, in the production environment, it generally runs in the specified server cluster.
  • In addition to load capacity, single point servers have other problems:
    • Limited storage capacity of a single machine
    • Single server is prone to single point of failure and cannot achieve high availability
    • The concurrent processing capability of a single service is limited

When configuring a server cluster, there is no limit on the number of nodes in the cluster. If there are more than or equal to 2 nodes, it can be regarded as a cluster. Generally, considering high performance and high availability, the number of nodes in the cluster is more than 3.

2. Cluster

A cluster is organized by one or more server nodes to jointly hold the whole data and provide it together
Index and search functions. An Elasticsearch cluster has a unique name ID, which is used by default
It is "elasticsearch". This name is important because a node can only join a cluster by specifying the name of the cluster.

3. Node

The cluster contains many servers, and a node is one of them. As part of the cluster, it stores
Data, participate in the index and search function of the cluster.
A node is also identified by a name. By default, this name is the name of a random Marvel comic character. This name will be given to the node at startup. This name is very important for management, because in
In this management process, you will determine which servers in the network correspond to which nodes in the Elasticsearch cluster.
A node can join a specified cluster by configuring the cluster name. By default, each node
Will be arranged to join a cluster called "elastic search", which means that if you start in your network
Several nodes, and assuming that they can find each other, they will automatically form and join a node called
In the cluster of "elasticsearch".

In a cluster, you can have as many nodes as you want. Moreover, if there is no traffic in your network at present
Line any elasticsearch node. When a node is started, a node called "elasticsearch" will be created and added by default
Cluster.

2. Windows cluster

1. Deploy cluster

  1. Create the elasticsearch cluster folder and internally copy three elasticsearch services
  2. Modify the config/elasticsearch.yml configuration file for each node in the cluster file directory
    node-1001 node
#Configuration information of node 1:
#Cluster name and nodes should be consistent
cluster.name: my-elasticsearch
#The node name must be unique in the cluster
node.name: node-1001
node.master: true
node.data: true
#ip address
network.host: localhost
#http port
http.port: 1001
#tcp listening port
transport.tcp.port: 9301
#discovery.seed_hosts: ["localhost:9301", "localhost:9302","localhost:9303"]
#discovery.zen.fd.ping_timeout: 1m
#discovery.zen.fd.ping_retries: 5
#List of nodes in the cluster that can be selected as the master node
#cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#Cross domain configuration
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

node-1002 node

#Configuration information of node 2:
#Cluster name and nodes should be consistent
cluster.name: my-elasticsearch
#The node name must be unique in the cluster
node.name: node-1002
node.master: true
node.data: true
#ip address
network.host: localhost
#http port
http.port: 1002
#tcp listening port
transport.tcp.port: 9302
discovery.seed_hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#List of nodes in the cluster that can be selected as the master node
#cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#Cross domain configuration
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"

node-1003 node

#Configuration information of node 3:
#Cluster name and nodes should be consistent
cluster.name: my-elasticsearch
#The node name must be unique in the cluster
node.name: node-1003
node.master: true
node.data: true
#ip address
network.host: localhost
#http port
http.port: 1003
#tcp listening port
transport.tcp.port: 9303
#The address of the candidate master node can be selected as the master node after the service is started
discovery.seed_hosts: ["localhost:9301", "localhost:9302"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
#List of nodes in the cluster that can be selected as the master node
#cluster.initial_master_nodes: ["node-1", "node-2","node-3"]
#Cross domain configuration
#action.destructive_requires_name: true
http.cors.enabled: true
http.cors.allow-origin: "*"
  1. Start cluster
    • Delete all contents (if any) in the data directory of each node before startup
    • Double click and execute bin/elasticsearch.bat respectively to start the node server. After startup, the node server with the specified name will be automatically added
      colony

4. Test cluster
View cluster status

  • node-1001 node
  • node-1002 node
  • node-1003 node

stateexplain
greenAll main and sub segments are in normal operation
yellowAll main segments are in normal operation, but not all sub segments are in normal operation
redThe main partition does not operate normally

Add indexes to node-1001 nodes in the cluster

Query the index of node-1002 in the cluster

Tags: Windows ElasticSearch

Posted on Tue, 12 Oct 2021 17:39:29 -0400 by ghornet