ELK Detailed Explanation (2) - Elasticsearch Installation and Deployment

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

1. Installation preparation

Before installing Elasticsearch, we first install the JAVA environment. The installation of the JAVA environment is described in detail in Tomcat (2) - tomcat installation and configuration , so I won't go into details here.
Then, we need to go to Elastic's official website to download the Elasticsearch installation package. The download site of the Elasticsearch official website is https://www.elastic.co/cn/downloads/elasticsearch , and the webpage is as follows:
insert image description here

Second, Elasticsearch installation and configuration

After downloading the Elasticsearch installation package, we execute the command:

yum localinstall -y elasticsearch-6.8.1.rpm

In this way, the installation of Elasticsearch can be completed.
Next, we configure Elasticsearch, open the Elasticsearch configuration file /etc/elasticsearch/elasticsearch.yml and
modify the configuration items as follows:
1. cluster.name
ELK cluster name, the device names in the same ELK cluster should be the same.
2. node.name
The name of the node in the ELK cluster, each device in the cluster should have its own name, and the name of each device should be different.
3. path.data
Elasticsearch data storage directory.
4. path.logs
Elasticsearch log storage directory.
5. network.host
Elasticsearch listening IP address.
6. http.port
Elasticsearch listening port number, the default is 9200.
7. discovery.zen.ping.unicast.hosts
The device IP address collected by Elasticsearch.
Note: The above parameters are all commented in the Elasticsearch configuration file, we can open it and modify it to the value we want. At the same time, there are also instructions for the use of the above parameters in the configuration file, we can refer to the instructions for configuration.
After that, we also need to configure the JAVA path of Elasticsearch, open /etc/sysconfig/elasticsearch, find the JAVA_HOME parameter, and modify it to our JAVA path, as follows:
insert image description here

3. Elasticsearch startup and access

After completing the above configuration of Elasticsearch, we can start Elasticsearch. The startup command is as follows:

systemctl start elasticsearch

After the startup is successful, the device will start listening on port 9200, and the results are as follows:
insert image description here
After Elasticsearch is started, we try to access Elasticsearch, and the results are as follows:
insert image description here

Fourth, Elasticsearch cluster status view

Since Elasticsearch is the concept of its own cluster, we generally need to deploy two Elasticsearches, and the configuration of the other is very similar to the previous configuration. The changes that need to be made are the node name (node.name) and the listening IP address ( network.host). After our configuration is complete, execute the command:

 curl http://X.X.X.X:9200/_cluster/health?pretty=true

Where XXXX is the IP address of any Elasticsearch device. The execution result of this command is as follows:
insert image description here
Pay attention to the status in the above figure. If the result is green, it means that the ELK system is running normally; if it is yellow, it means that some replica shards are lost, but it is not serious; if it is red, it means that the ELK system is running normally. The primary shard is lost and the system has a serious error.
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/123934313