(2) Rapid construction of ElasticSearch under Liunx

1. Download and install

1) Environment preparation:

Operating system: centos7
es version: 8.8.1
jdk: 17
es is compatible with jdk, etc. Support view

2) Download the installation package and upload it to the server, the official website address https://www.elastic.co/cn/downloads/elasticsearch

insert image description here

3) Unzip the file

tar -zxvf elasticsearch-8.8.1-linux-x86_64.tar.gz 

4) Start Elasticsearch

Enter the decompressed directory, enter the bin directory, and execute the command:

sh elasticsearch
# 守护进程方式
sh elasticsearch -d -p pid

Step on the pit

Start the error report and check the log to find
insert image description here
the reason: This is because Elasticsearch does not recommend running as the root user for security reasons. This is because running Elasticsearch as the root user can pose a potential security risk.
Solution: Create Elasticsearch users and groups:

sudo groupadd elasticsearch
sudo useradd -g elasticsearch elasticsearch

Change the ownership of the Elasticsearch directory:

#注意/usr/local/software/elasticsearch-8.8.1替换成自己解压es目录所在的位置
sudo chown -R elasticsearch:elasticsearch /usr/local/software/elasticsearch-8.8.1

Switch user and start elasticsearch

su elasticsearch

After switching, enter the bin directory and execute the startup command again sh elasticsearch.

5) Verify

Visit in the browser http://{服务器ip地址}:9200, if you can see a response in JSON format, which contains the version information of Elasticsearch, etc., it means that Elasticsearch has run successfully. Note that port 9200 is open.
insert image description here

Step on the pit:

Error when we visit

received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/172.16.5.10:9200,
remoteAddress=/172.16.11.68:11111}

As shown in the figure:
insert image description here
Reason: Elasticsearch8 enables security authentication by default.
Solution: In the elasticsearch.yml configuration file under the config/ directory, change the security authentication switch from the original true to false to achieve password-free login access. Modify as shown in the figure:
insert image description here

Guess you like

Origin blog.csdn.net/csdn570566705/article/details/131188215