elasticsearch - 无法将数据从mysql同步到logstash
问题描述
我的 logstash.conf 文件是
input {
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:8889/optjobs"
# The user we wish to execute our statement as
jdbc_user => "root"
jdbc_password => "root"
# The path to our downloaded jdbc driver
jdbc_driver_library => "/Users/ajoshi31/mysql-connector-java-5.1.17.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
# our query
statement => "SELECT * FROM candidates INNER JOIN candidate_skills ON candidate_skills.candidate_id = candidates.id"
}
}
output {
stdout { codec => json_lines }
elasticsearch {
"hosts" => "localhost:9200"
"index" => "optjobsprd"
"document_type" => "data"
}
}
使用配置文件并在运行 logstash
$ logstash -f logstash.conf
我收到以下错误
Thread.exclusive is deprecated, use Thread::Mutex
Sending Logstash logs to /usr/local/Cellar/logstash/7.5.2/libexec/logs which is now configured via log4j2.properties
[2020-04-09T11:47:14,307][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2020-04-09T11:47:14,549][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"7.5.2"}
[2020-04-09T11:47:17,657][INFO ][org.reflections.Reflections] Reflections took 122 ms to scan 1 urls, producing 20 keys and 40 values
[2020-04-09T11:47:18,565][ERROR][logstash.outputs.elasticsearch] Unknown setting '"document_type"' for elasticsearch
[2020-04-09T11:47:18,568][ERROR][logstash.outputs.elasticsearch] Unknown setting '"hosts"' for elasticsearch
[2020-04-09T11:47:18,572][ERROR][logstash.outputs.elasticsearch] Unknown setting '"index"' for elasticsearch
[2020-04-09T11:47:18,590][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:mai
一旦我删除了主机、document_type 和主机,logstash 就会运行,连接到 mysql 并执行查询,但我无法从 mysql 创建索引或更新数据。
解决方案
不得引用选项。删除引号,例如
output {
stdout { codec => json_lines }
elasticsearch {
hosts => "localhost:9200"
index => "optjobsprd"
document_type => "data"
}
}
推荐阅读
- android - 如何检查字符串是否在Arraylist中
或不? - python - 如何使用 python 在 Tensorboard 上显示训练和预测值
- sql - 如何在同一行中放入不同的值
- java - 此应用无权在 app-release.apk 中使用 Firebase 身份验证
- couchbase - Couchbase N1QL:根据另一个属性更新文档属性
- javascript - 在 IF 语句中使用关键字“this”
- php - 为什么这个 Doctrine 实体没有被持久化?
- php - 执行 exec 函数以在 bash 中编译 c 脚本的 PHP 脚本抛出错误
- python-3.x - 如何使用烧瓶为 abort 方法编写测试代码?
- mysql - ACID 事务,持久性