问题描述
我正在尝试在Ubuntu 18.04 LTS上使用logstash SystemV服务。每当我尝试使用 service 命令时,服务启动都会失败
# service logstash start && journalctl -u logstash
logstash.service: Failed to execute command: Exec format error
logstash.service: Failed at step EXEC spawning /usr/share/logstash/bin/logstash: Exec format error
我在服务器上为我的应用程序安装了 openjdk-11-jdk ,所以我想这就是logstash用于启动的内容:
# which java
/usr/bin/java
# /usr/bin/java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1,mixed mode,sharing)
我使用了来自:deb https://artifacts.elastic.co/packages/7.x/apt稳定主程序的APT安装了logstash
当Java兼容性问题出现时,似乎出现了此类错误,但应该来自Elastic文档OpenJDK 11和ubunetu 18.04 LTS上的logstash。
/etc/systemd/system/logstash.service文件是:
[Unit]
Description=logstash
[Service]
Type=simple
User=logstash
Group=logstash
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load,but if the file doesn't
# exist,it continues onward.
EnvironmentFile=-/etc/default/logstash
EnvironmentFile=-/etc/sysconfig/logstash
ExecStart=/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=16384
# When stopping,how long to wait before giving up and sending SIGKILL?
# Keep in mind that SIGKILL on a process can cause data loss.
TimeoutStopSec=infinity
[Install]
WantedBy=multi-user.target
使用以下命令:
/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"
似乎可以工作:
OpenJDK 64-Bit Server VM warning: Option UseConcmarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jruby.ext.openssl.SecurityHelper (file:/tmp/jruby-60735/jruby15836533716820282820jopenssl.jar) to field java.security.MessageDigest.provider
WARNING: Please consider reporting this to the maintainers of org.jruby.ext.openssl.SecurityHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Sending Logstash logs to /var/log/logstash which is Now configured via log4j2.properties
[2020-08-26T17:35:16,236][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.9.0","jruby.version"=>"jruby 9.2.12.0 (2.5.7) 2020-07-01 db01a49ba6 OpenJDK 64-Bit Server VM 11.0.8+10-post-Ubuntu-0ubuntu118.04.1 on 11.0.8+10-post-Ubuntu-0ubuntu118.04.1 +indy +jit [linux-x86_64]"}
....
[2020-08-26T17:35:24,858][INFO ][logstash.agent ] Pipelines running {:count=>1,:running_pipelines=>[:main],:non_running_pipelines=>[]}
[2020-08-26T17:35:25,057][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
解决方法
我的问题来自错误地自定义的 / usr / share / logstash / bin / logstash 文件,我删除了自定义的LS_JAVA_OPTS并成功。