首先看报错原因
[root@elk logstash]# /opt/elk/logstash/bin/logstash -e 'input{stdin{}}output{stdout{codec=>rubydebug}}'
Sending Logstash logs to /opt/elk/logstash/logs which is now configured via log4j2.properties
[2021-12-02T23:14:20,439][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.9.3", "jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 25.161-b14 on 1.8.0_161-b14 +indy +jit [linux-x86_64]"}
[2021-12-02T23:14:20,753][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
ERROR: Settings 'path.config' (-f) and 'config.string' (-e) can't be used simultaneously.
usage:
bin/logstash -f CONFIG_PATH [-t] [-r] [] [-w COUNT] [-l LOG]
bin/logstash --modules MODULE_NAME [-M "MODULE_NAME.var.PLUGIN_TYPE.PLUGIN_NAME.VARIABLE_NAME=VALUE"] [-t] [-w COUNT] [-l LOG]
bin/logstash -e CONFIG_STR [-t] [--log.level fatal|error|warn|info|debug|trace] [-w COUNT] [-l LOG]
bin/logstash -i SHELL [--log.level fatal|error|warn|info|debug|trace]
bin/logstash -V [--log.level fatal|error|warn|info|debug|trace]
bin/logstash --help
然后我又单独进行的一次启动:
[root@elk logstash]# ./bin/logstash
Sending Logstash logs to /opt/elk/logstash/logs which is now configured via log4j2.properties
[2021-12-02T23:11:06,924][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.9.3", "jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 25.161-b14 on 1.8.0_161-b14 +indy +jit [linux-x86_64]"}
[2021-12-02T23:11:07,262][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2021-12-02T23:11:07,286][INFO ][logstash.agent ] No persistent UUID file found. Generating new UUID {:uuid=>"8fa4bf61-3190-4e9d-ac9a-eccf68220b9f", :path=>"/opt/elk/logstash/data/uuid"}
[2021-12-02T23:11:07,618][INFO ][logstash.config.source.local.configpathloader] No config files found in path {:path=>"/opt/elk/logstash/conf.d/*"}
[2021-12-02T23:11:07,674][ERROR][logstash.config.sourceloader] No configuration found in the configured sources.
[2021-12-02T23:11:07,820][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
[2021-12-02T23:11:12,896][INFO ][logstash.runner ] Logstash shut down.
[2021-12-02T23:11:12,904][ERROR][org.logstash.Logstash ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SystemExit) exit
发现No config files found in path {:path=>"/opt/elk/logstash/conf.d/*"}
然后就想是不是我把path.config打开了,但是我没有往里面写配置的原因
我的logstash.yml文件
[root@elk logstash]# cat /opt/elk/logstash/config/logstash.yml
pipeline:
batch:
size: 125
delay: 5
path.config: /opt/elk/logstash/conf.d # conf.d目录自己创建
http.host: "0.0.0.0"
http.port: 9600-9700
log.level: info
path.logs: /opt/elk/logstash/logs
我将path.config注释掉之后
[root@elk logstash]# cat /opt/elk/logstash/config/logstash.yml
pipeline:
batch:
size: 125
delay: 5
#path.config: /opt/elk/logstash/conf.d # conf.d目录自己创建
http.host: "0.0.0.0"
http.port: 9600-9700
log.level: info
path.logs: /opt/elk/logstash/logs
再去启动测试:
[root@elk logstash]# /opt/elk/logstash/bin/logstash -e 'input{stdin{}}output{stdout{codec=>rubydebug}}'
Sending Logstash logs to /opt/elk/logstash/logs which is now configured via log4j2.properties
[2021-12-02T23:19:57,467][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.9.3", "jruby.version"=>"jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 25.161-b14 on 1.8.0_161-b14 +indy +jit [linux-x86_64]"}
[2021-12-02T23:19:57,792][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2021-12-02T23:19:58,815][INFO ][org.reflections.Reflections] Reflections took 28 ms to scan 1 urls, producing 22 keys and 45 values
[2021-12-02T23:19:59,369][INFO ][logstash.javapipeline ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>2, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>5, "pipeline.max_inflight"=>250, "pipeline.sources"=>["config string"], :thread=>"#<Thread:0x73bd9adb run>"}
[2021-12-02T23:19:59,904][INFO ][logstash.javapipeline ][main] Pipeline Java execution initialization time {"seconds"=>0.53}
The stdin plugin is now waiting for input:
[2021-12-02T23:19:59,936][INFO ][logstash.javapipeline ][main] Pipeline started {"pipeline.id"=>"main"}
[2021-12-02T23:19:59,995][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2021-12-02T23:20:00,131][INFO ][logstash.agent ] Successfully started Logstash API endpoint {:port=>9600}
{
"@timestamp" => 2021-12-02T15:20:01.792Z,
"@version" => "1",
"message" => "",
"host" => "elk"
}
启动成功。
总结报错原因,就是因为我的path.config打开了,但是我没有在conf.d目录里面写配置文件,导致找不到文件,一直报错。