欢迎来到 一木浮生 的博客

人生三重境界:昨夜西风凋碧树,独上高楼,望尽天涯路。 衣带渐宽终不悔,为伊消得人憔悴。 众里寻他千百度,蓦然回首,那人却在灯火阑珊处。
扩大
缩小

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配置

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

[root@elk-1-1 ~]# source /etc/profile
[root@elk-1-1 ~]# env | grep JAVA
JAVA_HOME=/usr/local/java

[root@elk-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

[elk@elk-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用来启动它

[elk@elk-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的内存大小

[elk@elk-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用户来运行的,我们必须提前创建一个用户!)

 

 

 

posted on 2018-07-28 15:57  一木浮生  阅读(6055)  评论(0编辑  收藏  举报

导航