ELK報錯及解決方案


ELK報錯及解決方案

 

1.jdk版本問題

報錯如下:

future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk9/jdk-9.0.4] does not meet this requirement
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

解決方案:

由於Elasticsearch依賴於jdk,es和jdk有着對應的依賴關系。具體可見:
https://www.elastic.co/cn/support/matrix
https://www.elastic.co/guide/en/elasticsearch/reference/7.2/setup.html
這里是說Elasticsearch該版本內置了JDK,而內置的JDK是當前推薦的JDK版本。當然如果你本地配置了JAVA_HOME那么ES就是優先使用配置的JDK啟動ES。
ES推薦使用LTS版本的JDK(這里只是推薦,JDK8就不支持),如果你使用了一些不支持的JDK版本,ES會拒絕啟動。
 
        

根據啟動信息我們看到Elasticsearch7.2推薦使用JDK11

jdk下載鏈接:https://www.oracle.com/technetwork/java/java-se-support-roadmap.html

安裝OpenJDK11

[root@ELK1 tar.gz]# pwd
/usr/local/src/tar.gz

#下載 [root@ELK1 tar.gz]# wget https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz

#加壓到指定目錄
[root@ELK1 tar.gz]# tar -xzvf jdk-11.0.4_linux-x64_bin.tar.gz /opt/

 

修改配置文件

[root@localhost bin]# vim /home/elk/elasticsearch/-7.2.1/bin/elasticsearch

#配置自己的jdk11
export JAVA_HOME=/opt/jdk-11.0.1
export PATH=$JAVA_HOME/bin:$PATH

#添加jdk判斷
if [ -x "$JAVA_HOME/bin/java" ]; then
        JAVA="/opt/jdk-11.0.1/bin/java"
else
        JAVA=`which java`
fi

  

啟動ES

[elasticsearch@ELK1 bin]$ ./elasticsearch
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2019-08-02T15:33:27,994][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [32.6gb], net total_space [35.7gb], types [rootfs]
[2019-08-02T15:33:28,014][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [1015.6mb], compressed ordinary object pointers [true]
[2019-08-02T15:33:28,017][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [8zGCWQhBS3OpVShqjSgU-w], cluster name [es-application]
[2019-08-02T15:33:28,017][INFO ][o.e.n.Node               ] [node-1] version[7.2.0], pid[1545], build[default/tar/508c38a/2019-06-20T15:54:18.811730Z], OS[Linux/3.10.0-862.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/11.0.1/11.0.1+13]
[2019-08-02T15:33:28,017][INFO ][o.e.n.Node               ] [node-1] JVM home [/opt/jdk-11.0.1]
[2019-08-02T15:33:28,018][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch-5247006010869253587, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Djava.locale.providers=COMPAT, -Dio.netty.allocator.type=unpooled, -XX:MaxDirectMemorySize=536870912, -Des.path.home=/usr/local/src/elasticsearch, -Des.path.conf=/usr/local/src/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true]

  

2.啟動elasticsearch報錯

報錯如下:

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2019-08-08T16:04:33,578][INFO ][o.e.n.Node               ] [ELK1] stopping ...
[2019-08-08T16:04:33,591][INFO ][o.e.n.Node               ] [ELK1] stopped
[2019-08-08T16:04:33,592][INFO ][o.e.n.Node               ] [ELK1] closing ...
[2019-08-08T16:04:33,618][INFO ][o.e.n.Node               ] [ELK1] closed
[2019-08-08T16:04:33,621][INFO ][o.e.x.m.p.NativeController] [ELK1] Native controller process has stopped - no new native processes can be started

  

解決方法:

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

每個進程最大同時打開文件數太小,可通過下面2個命令查看當前數量
ulimit -Hn
ulimit -Sn

修改/etc/security/limits.conf文件,增加配置,用戶退出后重新登錄生效

*               soft    nofile          65536
*               hard    nofile          65536

#2、max number of threads [3818] for user [es] is too low, increase to at least [4096]

#問題同上,最大線程個數太低。修改配置文件/etc/security/limits.conf,增加配置

*               soft    nproc           4096
*               hard    nproc           4096

#可通過命令查看

ulimit -Hu
ulimit -Su

  

3.在安裝elasticsearch-head的過程中npm install報錯

報錯如下:

[root@ELK1 elasticsearch-head]# npm install 
npm: relocation error: npm: symbol SSL_set_cert_cb, version libssl.so.10 not defined in file libssl.so.10 with link time reference

 

解決方法:

升級openssl,執行:
yum update openssl -y

#升級之前版本信息:

[root@ELK1 elasticsearch-head]# openssl version
OpenSSL 1.0.1i 6 Aug 2014

#升級之后:

[root@ELK elasticsearch-head]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017

此時再次執行,報錯消除

  

4.啟動logstash報錯

報錯如下:

Thread.exclusive is deprecated, use Thread::Mutex
Sending Logstash logs to /data/logstash/logs which is now configured via log4j2.properties
[2019-08-08T17:23:59,508][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-08-08T17:23:59,519][FATAL][logstash.runner          ] Logstash could not be started because there is already another instance using the configured data directory.  If you wish to run multiple instances, you must change the "path.data" setting.
[2019-08-08T17:23:59,527][ERROR][org.logstash.Logstash    ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit

  

原因:之前運行的instance有緩沖,保存在path.data里面有.lock文件,刪除掉就可以

解決方法:

在 logstash.yml 文件中找到 Data path 的路徑(默認在安裝目錄的data目錄下)

# ------------ Data path ------------------
#
# Which directory should be used by logstash and its plugins
# for any persistent needs. Defaults to LOGSTASH_HOME/data
#
path.data: 

  

查看是否存在 .lock 文件,如果存在把它刪除

[root@ELK1 data]# ls -alh
總用量 20K
drwxr-sr-x  4 tingshuo staff 4.0K 8月 19 11:42 .
drwxr-sr-x 14 tingshuo staff 4.0K 8月 19 11:42 ..
drwxr-sr-x  2 tingshuo staff 4.0K 8月 19 11:42 dead_letter_queue
-rw-r--r--  1 tingshuo staff    0 8月 19 11:42 .lock
drwxr-sr-x  2 tingshuo staff 4.0K 8月 19 11:42 queue
-rw-r--r--  1 tingshuo staff   36 8月 19 11:42 uuid

  

刪除

[root@ELK1 data]# rm .lock

  

5.Logstash 報錯: A plugin had an unrecoverable error. Will restart this plugin

解決方法:

因為斷開終端,進程還存在

[root@Elk1 ~]# ps aux | grep logstash
root     12180  1.6  4.5 6912300 744896 ?      Sl   Oct18  69:39 /usr/bin/java -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Xss2048k -Djffi.boot.library.path=/opt/logstash/vendor/jruby/lib/jni -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/logstash/heapdump.hprof -Xbootclasspath/a:/opt/logstash/vendor/jruby/lib/jruby.jar -classpath : -Djruby.home=/opt/logstash/vendor/jruby -Djruby.lib=/opt/logstash/vendor/jruby/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main --1.9 /opt/logstash/lib/bootstrap/environment.rb logstash/runner.rb agent -f /etc/logstash/conf.d/filebeat.conf
root     16921  0.0  0.0 103244   864 pts/2    S+   15:28   0:00 grep 12180
[root@Elk1 ~]# kill 12180

  

殺掉這個沒有正常關閉的前台測試 Logstash 進程,重啟logstash。

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM