Logstash(5.5.2)踩过的坑

版本:
os:ubuntu 16.04
logstash:5.5.2

logstash安装方式:通过apt install 安装
安装文档: https://www.elastic.co/guide/en/x-pack/5.5/installing-xpack.html

异常:
1、ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
2、ERROR Unable to create file /var/log/logstash/logstash-plain.log java.io.IOException: Permission denied

异常信息:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults
原因:找不到配置文件
解决:在命令后面,加上一个参数,指定配置文件目录
sudo bin/logstash -e 'input { stdin { } } output { stdout {} }' --path.settings=/etc/logstash

没有io写权限
异常信息:
ERROR Unable to create file /var/log/logstash/logstash-plain.log java.io.IOException: Permission denied
原因:logstash对输出日志的目录没有权限
解决:为使用的账户添加该目录的写权限(推荐),另外一种方便的做法是,使用sudo 来启动命令(不推荐)
sudo bin/logstash -e 'input { stdin { } } output { stdout {} }' --path.settings=/etc/logstash

问题现象:使用apt 方式安装,出现下面的异常信息,并且在安装后使用,使用 sudo systemctl start logstash . service ,或者service logstash start,报异常信息
1、Failed to start logstash.service: Unit logstash.service not found. ubuntu
2、Using provided startup.options file: /etc/logstash/startup.options
/usr/share/logstash/vendor/jruby/bin/jruby: line 388: /usr/bin/java: No such file or directory
Unable to install system startup script for Logstash.
3、/usr/share/logstash/vendor/jruby/bin/jruby: line 388: /usr/bin/java: Is a directory
/usr/share/logstash/vendor/jruby/bin/jruby: line 388: exec: /usr/bin/java: cannot execute: Is a directory
Unable to install system startup script for Logstash.
4、Using provided startup.options file: /etc/logstash/startup.options
/usr/share/logstash/vendor/jruby/bin/jruby: line 388: /usr/bin/java: Is a directory
/usr/share/logstash/vendor/jruby/bin/jruby: line 388: exec: /usr/bin/java: cannot execute: Is a directory
Unable to install system startup script for Logstash. 原因:Logstash在安装过程中,找不到 /usr/bin/java文件,导致安装脚本不能Logstash 启动文件配置到系统的系统的脚本,所以出现上面的异常信息。 解决:在/usr/bin/目录下创建一个java的软连接到自己安装的jdk中的bin/java文件,这样Logstash安装脚本才会执行,把Logstash 启动文件配置到系统的系统的脚本中。然后卸载Logstash,并重新安装Logstash
sudo ln -s jdkpath/jdk1.8.0_144/bin/java /usr/bin/java
sudo apt install logstash 
sudo apt remove logstash



参考:

https://github.com/elastic/logstash/issues/6921

https://github.com/elastic/logstash/issues/6582

https://stackoverflow.com/questions/44468361/i-cannot-start-logstash-on-my-machine-error-message-inside/46127313#46127313 (如果解决了你们的问题化,望大家给这个回答投下票)

你可能感兴趣的:(ELK)