- 运行
logstash -f ../mysqlconfig/mysql.conf
报错,:message=>"Expected one of #, {, ", ', } at line 13, column 1 (byte 497) after input {stdin{}\njdbc
启动logstash时,报错如下:
[2021-04-22T16:29:20,994][ERROR][logstash.agent] Failed to execute action
{:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError",
:message=>"Expected one of #, {, \", ', } at line 4, column 1 (byte 141) after input {stdin{}\njdbc
{\njdbc_connection_string => \"jdbc:mysql://localhost:3306/es?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC\"\n",
:backtrace=>[
"E:/softwares/logstash-6.3.2/logstash-core/lib/logstash/compiler.rb:42:in `compile_imperative'",
"E:/softwares/logstash-6.3.2/logstash-
core/lib/logstash/compiler.rb:50:in `compile_graph'",
"E:/softwares/logstash-6.3.2/logstash-
core/lib/logstash/compiler.rb:12:in `block in compile_sources'", "org/jruby/RubyArray.java:2486:in `map'", "E:/softwares/logstash-6.3.2/logstash-core/lib/logstash/compiler.rb:11:in `compile_sources'",
"E:/softwares/logstash-6.3.2/logstash-core/lib/logstash/pipeline.rb:49:in `initialize'",
"E:/softwares/logstash-6.3.2/logstash-core/lib/logstash/pipeline.rb:167:in `initialize'",
"E:/softwares/logstash-6.3.2/logstash-core/lib/logstash/pipeline_action/create.rb:40:in `execute'",
"E:/softwares/logstash-6.3.2/logstash-core/lib/logstash/agent.rb:305:in `block in converge_state'"
]}
百度了无数遍都说是mysql.config编码问题,要改utf-8,有的说改成ANSI编码,感觉都很有道理,在没解决的情况下,也只能是去尝试了。
- 在nodepad++和记事本从utf-8编码设置成ANSI编码,演示Nodepad++如下
却演变成了乱码问题,偷鸡不成蚀把米。
后来发现报错有这么一句:"Expected one of #, {, \", ', } at line 4, column 1 (byte 141) after input {stdin{}\njdbc"
错误,果然是编码的问题。
- 解决方法:逐行检查并清除所有的#、反斜线 \、中文及中文符号、\n换行等等,统统删除,查看效果
最终如下一般清晰
- 再次运行
logstash -f ../mysqlconfig/mysql.conf
有点不敢相信,居然成功了