一、报错与解决过程
docker run -d --name logstash -p 14560:4560 -v /root/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml -v /root/logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf logstash:8.1.3
在docker上部署logstash的时候,刚把容器启动没一会儿就挂了,重启好几遍,还是会没一会就挂掉,查看日志发现以下信息:
“LogStash::ConfigurationError”, :message=>“Expected one of [ \t\r\n], “#”, “{”, “}” at line 3, column 21 (byte 37) after input {\n tcp {\n mode => “server””, :backtrace=>[“/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:32:in
compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:189:in
initialize’”, “org/logstash/execution/JavaBasePipelineExt.java:72:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:47:in
initialize’”, “/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:50:inexecute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:376:in
block in converge_state’”]}
根据日志来看,报错的原因是配置文件出现了错误,仔细检查自己的配置文件,到底是没错啊,怎么就会报配置错误呢。
于是,按照日志信息的提示区配置文件的相应位置找问题,最终发现每个配置项的后面几乎都多了好几个空格,说多了都是泪啊😭😭😭。最终把多余的空格去掉后启动成功。
二、写在最后
重要的事情说三遍:logstash配置文件配置项末尾不要有空格!!! logstash配置文件配置项末尾不要有空格!!! logstash配置文件配置项末尾不要有空格!!!