当前位置: 首页 > 工具软件 > Java Gems > 使用案例 >

logstash java_Logstash设置独立JAVA环境

季阳朔
2023-12-01

因为在生产环境上需要上线一套ELK环境,但是日志收集程序Logstash需要依赖对应版本的JDK环境,具体的版本依赖在下载时有提示,提示如下:https://www.elastic.co/downloads/logstashVersion:

6.1.3

Release date:

January 30, 2018

Notes:

View detailed release notes.

Not the version you're looking for? View past releases.Java 8 is required for Logstash 6.x and 5.x.

可以看出需要依赖Java 8的环境。但是在生产系统中,已经部署好jdk1.7环境,而且无法轻易更改,如果不配置Java 8,会启动失败,报错信息如下:

[root@server17 bin]# /opt/logstash-5.2.0/bin/logstash -e

LoadError: JRuby ext built for wrong Java version in `com.purbon.jrmonitor.JRMonitorService': java.lang.UnsupportedClassVersionError: com/purbon/jrmonitor/JRMonitorService : Unsupported major.minor version 52.0

require at org/jruby/RubyKernel.java:1040

(root) at /opt/logstash-5.2.0/vendor/bundle/jruby/1.9/gems/jrmonitor-0.4.2/lib/jrmonitor.rb:4

require at org/jruby/RubyKernel.java:1040

(root) at /opt/logstash-5.2.0/logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb:1

require at org/jruby/RubyKernel.java:1040

(root) at /opt/logstash-5.2.0/logstash-core/lib/logstash/instrument/periodic_poller/jvm.rb:5

require at org/jruby/RubyKernel.java:1040

(root) at /opt/logstash-5.2.0/logstash-core/lib/logstash/instrument/periodic_pollers.rb:1

require at org/jruby/RubyKernel.java:1040

(root) at /opt/logstash-5.2.0/logstash-core/lib/logstash/instrument/periodic_pollers.rb:3

require at org/jruby/RubyKernel.java:1040

(root) at /opt/logstash-5.2.0/lib/bootstrap/environment.rb:70

因此需要对Logstash配置单独的Java环境,只需要分别在如下两个配置文件里面配置Java环境即可:

export JAVA_HOME=/usr/local/jdk1.8

1、~/logstash-5.2.0/bin/logstash

2、~/logstash-5.2.0/bin/logstash.lib.sh

 类似资料: