Article Directory
Prerequisites:
1. Linux system
3. Turn off firewall and SElinux
Step 1: Install JDK (ES comes with OpenJDK, the step of installing JDK can be omitted as needed)
Step 2: Download
https://www.elastic.co/cn/start
Step 3: Upload and unzip
First upload it to a directory, you can use the lrzsz tool, if not (yum -y install lrzsz) upload it with rz.
rz
tar -zxvf elasticsearch-7.11.1-linux-x86_64.tar.gz
Step 3.5: Permission issues
Create a new user
useradd es,
set the permissions of the directory to the new user
chown -R es:es /test/elasticsearch-7.11.1/
switch to the new user for the following operations
(because the operation of ES is not recommended to use the root user)
Step 4: Change the configuration
cd elasticsearch-7.11.1/config/
vim elasticsearch.yml
This configuration file is fully annotated by default. You need to uncomment the following items and fill in the corresponding content.
cluster.name ES集群名称,随便填
node.name ES安装的这台节点的主机名
http.port: 9200
network.host: 0.0.0.0 这个是让任意地址都能访问es
discovery.seed_hosts:["192.168.xx.xx"] 这里是这台机器的ip地址
cluster.initial_master_nodes:["xxx"] 这里xxx是node.name的值
Save and exit
Step 5: Start
Clone a new window to start, easy to view the startup log, or write the log to a file
cd /test/elasticsearch-7.11.1/bin/
./elasticsearch
Step 6: Verify that the installation is successful
The browser accesses port 9200 of the ip address of this machine
http://192.168.xx.xxx:9200/
Will return a large piece of JSON format code
{
"name" : "elk",
"cluster_name" : "my-application",
"cluster_uuid" : "-R6LYlMoS2qqMr6r3Ynb_g",
"version" : {
"number" : "7.11.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "ff17057114c2199c9c1bbecc727003a907c0db7a",
"build_date" : "2021-02-15T13:44:09.394032Z",
"build_snapshot" : false,
"lucene_version" : "8.7.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
In this way, the installation is successful. More configurations can be found in official documents.
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
BUG finishing
BUG01 vm.max_map_count [65530] is too low
The following error occurred after installation:
[2021-02-21T19:18:09,221][INFO ][o.e.b.BootstrapChecks ] [node01] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /export/servers/elasticsearch-7.11.1/logs/elasticsearch.log
Solution:
Open the following file
vi /etc/sysctl.conf
Add or modify the following content
vm.max_map_count=655360
carried out
sysctl -p
Just restart ElasticSearch.
BUG02 Cannot access port 9200 of this host address from other ip after installation on centos8
After analysis, it may be caused by the firewall and selinux not being closed.
First consider the firewall, but generally centos8 will not bring the firewall service after the successful installation, then it should be a selinux problem.
Enter sestatus to view the selinux status.
[root@node01 bin]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 32
[root@node01 bin]#
Found that it is indeed turned on, just turn it off.
- Command: temporarily shut down selinux
setenforce 0
Modify the configuration and restart centos8 to change the behavior of
vi /etc/selinux/config
to disabled
SELINUX=disabled
Check selinux status after restarting the computer:
[root@node01 ~]# sestatus
SELinux status: disabled
[root@node01 ~]#
The shutdown is successful, now restart es, and try to access port 9200.
Successfully started!