elasticsearch7.0.1 installation and configuration optimization in Centos7.5

Briefly describe the ES out of the box, you can play with the search engine without any configuration. The following is the process of installing ES in centos7.5.
Note: the following process is to build a cluster of three nodes simulated on a server.

server information

Server IPInstallation pathhttp porttransport portoperating systemES versionNode name

Create elastic user

useradd -m elastic

Modify system configuration information

  • Disabling switching and enabling the virtual memory exchange function of the server will be a fatal blow to elasticsearch
sudo swapoff -a
  • Add /etc/sysctl Conf configuration, execute sysctl -p to take effect
vi /etc/sysctl.conf
sysctl -p
  • Add /etc/security/limits Conf configuration
vi /etc/security/limits.conf 
elastic soft nofile 100001
elastic hard nofile 100002
elastic soft memlock unlimited
elastic hard memlock unlimited

Download and unzip

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
tar -zxf elasticsearch-7.0.1-linux-x86_64.tar.gz 
mv elasticsearch-7.0.1 /usr/local/elk-7.0.1/

Deploy ES

  • Modify the permissions of elasticsearch directory
chown -R elastic.elastic /usr/local/elk-7.0.1/elasticsearch-7.0.1
  • jvm.options configuration file

jvm.options is mainly used to configure java virtual machine. The official recommendation is that the memory allocated to es should not exceed 50% of the system memory, and half of it should be reserved for Lucene, because Lucene will cache segment data to improve retrieval performance; The memory configuration should not exceed 32g. If your server memory is not much more than 64g, it is not recommended to set the JVM memory of ES to 32g, because the length of each JVM object pointer will double after 32g, resulting in increased memory and cpu overhead.

vi config/jvm.options
  • elasticsearch.yml configuration file
vi config/elasticsearch.yml

Basic configuration:

# Configure the es cluster name, and the cluster with the same name will be recognized automatically
cluster.name: test-cluster
# es7.0 cluster node name will automatically obtain the local hostname. If it is not a multi instance deployment, this item can not be configured
node.name: node-1
# Master node or not
node.master: true 
# Whether to open the data node
node.data: true
# Preprocessing data 
node.ingest: true 
# Specify the data storage directory. Multiple directories are separated by commas. You can configure the relative ES root directory path
path.data: data
# Specify the log storage directory, and you can configure the relative ES root directory path
path.logs: logs
# Specify the local ip address
# Specify the http protocol port. The default is 9200. It needs to be modified during multi instance deployment
http.port: 59201
# Allow cross domain requests
http.cors.enabled: true
# Addresses that allow cross domain requests, * represents all
http.cors.allow-origin: "*"
# Specify the tcp protocol port, which is 9300 by default. It needs to be modified during multi instance deployment
transport.port: 59301
# Broadcast node
discovery.seed_hosts: ["", "", ""]
# Specify the list of primary nodes. This parameter needs to be configured on each node. It can be node name or IP address
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
# Prevent initial recovery after a full cluster restart until n nodes are started
gateway.recover_after_nodes: 3
# Setup license (basic version)
xpack.license.self_generated.type: basic

Optimized configuration:

# Set to true to lock the memory. When the service has mixed deployment of multiple components and services, this operation should be enabled to allow es to occupy enough memory.
bootstrap.memory_lock: true
# Set the memory fusing limit of a single request, which is 60% of the jvm heap by default (es7.0 introduces a new memory fusing mechanism, which can make intelligent judgments and avoid OOM).
indices.breaker.request.limit: 10%
# Set the number of threads used in segment merging. The more configured threads, the greater the disk io consumption (SSD ignored).
#index.merge.scheduler.max_thread_count: 1
# query requests the jvm memory limit that can be used. The default is 10%.
indices.queries.cache.size: 20%
# Query the DSL statement cache of request request. The cached DSL statement will not be parsed again the next time it is requested, which can improve the retrieval performance. The default value is 1%.
indices.requests.cache.size: 2%
# Set the maximum value of the field cache, which is unlimited by default.
indices.fielddata.cache.size: 30%
# It is used to separate hot and cold index data. It should be noted that the setting should also be configured with "index.routing.allocation.require.box_type": "hot"
node.attr.box_type: hot

Node 2 and node 3 copy the ES configured above. On this basis, modify the following parameters in the elasticsearch.yml configuration file:

node.name: node-2
http.port: 59203
transport.port: 59303
node.name: node-3
http.port: 59205
transport.port: 59305

Install plug-ins

Install the Chinese word segmentation plug-in IK. The plug-in version should be consistent with the ES version. Execute the following command to install it:

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.0.1/elasticsearch-analysis-ik-7.0.1.zip

Install the pinyin plug-in. The plug-in version should be consistent with the ES version. Execute the following command to install it:

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.0.1/elasticsearch-analysis-pinyin-7.0.1.zip

Each node needs to be installed, or copy the ES after installation.

Start ES

su - elastic -c '/opt/elasticsearch/bin/elasticsearch -d'

ES common address

 1. View node status
 2. View cluster status

ES cluster node role configuration combination

Tags: ElasticSearch

Posted by kparish on Tue, 09 Aug 2022 22:13:49 +0530