elasticsearch启动错误整理

Posted sky-k

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch启动错误整理相关的知识,希望对你有一定的参考价值。

一、elasticsearch错误复现

(一)、环境

配置环境
  OS:CentOS 7.4 64bit
  elasticsearch版本:5.4.1
  hostname:elk-1-1
  ip:10.18.43.170
   java版本:java -version "1.8.0_181"

(二)、错误复现

  首先要获取必须的软件包

wget -P /var/ftp/ https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.1.tar.gz

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz"

环境配置

sed -ri /^SELINUX/cSELINUX=disabled /etc/selinux/config
setenforce 0

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-port=9200/tcp
firewall-cmd --permanent --add-port=9300/tcp
firewall-cmd --reload

JDK配置

[[email protected]1-1 ~]# tar xf jdk-8u181-linux-x64.tar.gz -C /usr/local/
[[email protected]-1-1 ~]# ln -s /usr/local/jdk1.8.0_181 /usr/local/java
[[email protected]-1-1 ~]# cat /etc/profile.d/java.sh
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH

[[email protected]-1-1 ~]# source /etc/profile
[[email protected]-1-1 ~]# env | grep JAVA
JAVA_HOME=/usr/local/java

[[email protected]-1-1 ~]# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

elasticsearch配置

useradd elk
su - elk
mv /tmp/elasticsearch-5.4.1.tar.gz /home/elk
tar xf elasticsearch-5.4.1.tar.gz

配置文件elasticsearch-5.4.1/config/elasticsearch.yml

[[email protected]1-1 ~]$ egrep "^[^#$]" elasticsearch-5.4.1/config/elasticsearch.yml 
cluster.name: my-elk
node.name: elk1
path.data: /tmp/data
path.logs: /tmp/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200

elasticsearch不允许root用启动,我使用给他专门创建的用户elk用来启动它

[[email protected]1-1 ~]$ elasticsearch-5.4.1/bin/elasticsearch -d

(三)、日志输出

[2018-07-27T19:19:16,089][ERROR][o.e.b.Bootstrap          ] [elk1] node validation exception
[3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: memory locking requested for elasticsearch process but memory is not locked
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

二、解决方法

错误一:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

解决方法:

  打开/etc/security/limits.conf文件,在末尾添加以下两行并保存:

* soft nofile 65536     //*表示任意用户,这里是elasticsearch报的错,也可以直接填运行elk的用户;
* hard nofile 131072

错误二:

[2]: memory locking requested for elasticsearch process but memory is not locked

解决方法:

  修改elasticsearch.yml文件

bootstrap.memory_lock : false

错误三:

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方法:

  修改内核配置/etc/sysctl.d/99-sysctl.conf添加vm.max_map_count=262144

sysctl -w vm.max_map_count=262144
sysctl -p

错误四:

os::commit_memory(0x00000001006cd000, 77824, 0) failed; error=’Cannot allocate memory’ (errno=12)

解决方法:

  提供内存不足,增大主机内存或者减小elasticsearch的内存大小

[[email protected]1-1 ~]$ grep -v "^#" elasticsearch-5.4.1/config/jvm.options |grep -v "^$"
-Xms2g
-Xmx2g
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+DisableExplicitGC
-XX:+AlwaysPreTouch
-server
-Xss1m
-Djava.awt.headless=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-Djdk.io.permissionsUseCanonicalPath=true
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-Dlog4j.skipJansi=true
-XX:+HeapDumpOnOutOfMemoryError

  修改完成之后,建议退出当前登录用户,在重新登录,然后在重新启动elasticsearch,就可以一了,(:tar包和unzip包,都是不允许elasticsearch程序让root用户来运行的,我们必须提前创建一个用户!)

 

 

 

以上是关于elasticsearch启动错误整理的主要内容,如果未能解决你的问题,请参考以下文章

ElasticSearch学习问题记录——Invalid shift value in prefixCoded bytes (is encoded value really an INT?)(代码片段

elasticsearch启动错误求解

elasticsearch启动常见错误

IOS开发-OC学习-常用功能代码片段整理

解决elasticsearch启动时常见的错误

解决elasticsearch启动时常见的错误