2.0 Elasticsearch7.1 ES在Linux下安裝問題處理(外網訪問良心優化版)

txidol-Fly發表於2020-09-28

下載解壓

各個版本都有
https://elasticsearch.cn/download/

[root@localhost hadoop]# tar -zxf jdk-11.0.8_linux-x64_bin.tar.gz -C /usr/local/java
[root@localhost hadoop]# tar -zxf elasticsearch-7.1.0-linux-x86_64.tar.gz -C /usr/local
[root@localhost hadoop]# tar -zxf filebeat-7.1.0-linux-x86_64.tar.gz -C /usr/local
[root@localhost hadoop]# tar -zxf kibana-7.1.0-linux-x86_64.tar.gz -C /usr/local
[root@localhost hadoop]# tar -zxf logstash-7.1.0.tar.gz -C /usr/local

JVM配置

在es目錄修改JVM - config/jvm.options 7.1預設設定1GB
配置建議 Xmx 和 Xms一樣 Xmx不超過機器記憶體50% 不超過30GB

vim /etc/profile
export JAVA_HOME=/usr/local/install/jdk-11.0.8
export PATH=$JAVA_HOME/bin:$PATH

問題一 java.lang.RuntimeException: can not runelasticsearch as root

[root@iZbp1bb2egi7w0ueys548pZ local]# chown -R hadoop elasticsearch-6.0.0
切換至elasticsearch使用者
[root@iZbp1bb2egi7w0ueys548pZ etc]# su elasticsearch

使用後臺啟動方式啟動:./elasticsearch -d

問題二 ES不能外網訪問

elasticsearch.yml

network.host: 192.168.188.100
# 本機地址或者 network.host: 0.0.0.0
# Set a custom port for HTTP:
#
http.port: 9200

問題三 ES不能外網訪問 解決了一大波問題但是還不能訪問

試試關了防火牆

service firewalld stop
 
#檢視防火牆狀態 
systemctl status firewalld.service 
#臨時關閉防火牆 
systemctl stop firewalld.service 
#禁止firewall開機啟動 
systemctl disable firewalld.service

問題四 failed to obtain node locks

Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/elasticsearch-7.1.0/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

先前啟動的沒殺乾淨

[hadoop@fly elasticsearch-7.1.0]$ jps
23696 Elasticsearch
24314 Jps
[hadoop@fly elasticsearch-7.1.0]$ kill -9 23696

問題五 seccomp unavailable 錯誤 這個我7.1我沒遇到

解決方法:elasticsearch.yml 配置
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

問題六 max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

vim /etc/security/limits.conf ***填啟動es使用者 我的是hadoop
*** hard nofile 80000
*** soft nofile 80000

To Increase the File Descriptor Limit (Linux) 其他材料我就用了第六招:
不見效果 記得重啟 reboot

ulimit -Hn 立馬變了

1.	Display the current hard limit of your machine.
The hard limit is the maximum server limit that can be set without tuning the kernel parameters in proc file system.
$ ulimit -aH
core file size (blocks)       unlimited
data seg size (kbytes)        unlimited
file size (blocks)            unlimited
max locked memory (kbytes)    unlimited
max memory size (kbytes)      unlimited
open files                    1024
pipe size (512 bytes)         8
stack size (kbytes)           unlimited
cpu time (seconds)            unlimited
max user processes            4094
virtual memory (kbytes)       unlimited
2.	Edit the /etc/security/limits.conf and add the lines:
*     soft   nofile  1024
*     hard   nofile  65535 
3.	Edit the /etc/pam.d/login by adding the line:
session required /lib/security/pam_limits.so
4.	Use the system file limit to increase the file descriptor limit to 65535.
The system file limit is set in /proc/sys/fs/file-max .
echo 65535 > /proc/sys/fs/file-max
5.	Use the ulimit command to set the file descriptor limit to the hard limit specified in /etc/security/limits.conf.
ulimit -n unlimited
6.	Restart your system.

問題七 max virtual memory areas vm.max_map_count [65530] is too low

vim /etc/sysctl.conf 
vm.max_map_count = 262144

然後 sysctl -p 生效

問題八 the default discovery settings are unsuitable…, last least one of […] must be configured

解決方法:elasticsearch.yml 開啟配置:

node.name: node-1
cluster.initial_master_nodes: ["node-1"]

相關文章