ELK Detailed Explanation (3) - Elasticsearch Deployment Optimization

Today, I will continue to introduce Linux operation and maintenance related knowledge. The main content of this article is the deployment optimization of Elasticsearch.

1. Hardware requirements

In ELK Detailed Explanation (2) - Elasticsearch Installation and Deployment , we installed and deployed Elasticsearch. But in this article, we only get Elasticsearch up and running, but there is still a lot of room for improvement in its new features. Today, we will explain the deployment optimization method of Elasticsearch.
The deployment optimization of Elasticsearch should first be based on the system having certain hardware resources. In the above, the system hardware resources are as follows: As
insert image description here
you can see, the virtual machine only has 2 GB of memory, which is far from enough. This is also mentioned above. There is no reason for optimization in the text. Before the deployment optimization in this article, we must first adjust the hardware memory of the Elasticsearch device to more than 3 G.

Second, the configuration file modification

To optimize Elasticsearch, the main thing is to set the memory lock. After using the memory lock, Elasticsearch can lock the memory of the specified size at startup, avoiding the use of swap swap partitions due to insufficient free memory, resulting in the performance of Elasticsearch. There was a problem. Elasticsearch's memory settings are configured as follows:

(1) Elasticsearch configuration file modification

Open the Elasticsearch configuration file: /etc/elasticsearch/easticsearch.yml, find the bootstrap.memory_lock parameter, and modify it to true, as shown below:
insert image description here

(2) Modification of system service configuration files

After that, we modify the system service configuration file, open the /usr/lib/systemd/system/elasticsearch.service file, and add the following content under the service module:

LimitMEMOLOCK=infinity

It is used to indicate that Elasticsearch can use memory without limit. The file after configuration is as follows:
insert image description here

(3) JVM configuration file modification

Finally, let's modify Elasticsearch's JVM configuration file, open /etc/elasticsearch/jvm.options, and put the content in it:

-Xms1g
-Xmx1g

change into:

-Xms2g
-Xmx2g

It means that the initial latch memory and the maximum latch memory size of Elasticsearch are both 2 G. The modified configuration file is as follows:
insert image description here
After completing all the above configurations, we restart the Elasticsearch service to make our configuration effective!
Originality is not easy, please indicate the source for reprinting: https://blog.csdn.net/weixin_40228200

Guess you like

Origin blog.csdn.net/weixin_40228200/article/details/123940424