微信搜索superit|邀请体验:大数据, 数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

elasticsearch启动错误整理

elasticsearch aide_941 33℃

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

=————-

http://192.168.75.188:9200/_cat/nodes?v

结果:{“error”:{“root_cause”:[{“type”:”master_not_discovered_exception”,”reason”:null}],”type”:”master_not_discovered_exception”,”reason”:null},”status”:503}

感谢大家,之前的问题自己已经解决,因为这个虚拟机是克隆过来的,所以需要将另外两个节点中的data目录下的所有文件删除即可
https://blog.csdn.net/gamer_gy … 77189  附带这个链接,有详细解读一些坑

转载请注明:SuperIT » elasticsearch启动错误整理

喜欢 (0)or分享 (0)