logstash通过mysql数据库多张表
Posted huangfeialllen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了logstash通过mysql数据库多张表相关的知识,希望对你有一定的参考价值。
1.下载logstash
https://www.elastic.co/cn/downloads/logstash
2.配置
input {
stdin {
}
jdbc {
type => "tb_role"
jdbc_connection_string => "jdbc:mysql://192.168.3.167:3306/zwls?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true"
jdbc_user => "root"
jdbc_password => "123456"
record_last_run => "true"
use_column_value => "true"
tracking_column => "id"
clean_run => "false"
jdbc_driver_library => "D:softsoftinstallapache-maven-3.3.9
espmysqlmysql-connector-java8.0.16mysql-connector-java-8.0.16.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "500"
statement => "select * from tb_role"
schedule => "* * * * *"
}
jdbc {
type => "tb_order"
jdbc_connection_string => "jdbc:mysql://192.168.3.167:3306/zwls?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true"
jdbc_user => "root"
jdbc_password => "123456"
record_last_run => "true"
use_column_value => "true"
tracking_column => "order_id"
clean_run => "false"
jdbc_driver_library => "D:softsoftinstallapache-maven-3.3.9
espmysqlmysql-connector-java8.0.16mysql-connector-java-8.0.16.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_paging_enabled => "true"
jdbc_page_size => "500"
statement => "select * from tb_order"
schedule => "* * * * *"
}
}
output {
if [type]=="tb_order" {
elasticsearch {
#ESIP地址与端口
hosts => "localhost:9200"
#ES索引名称(自己定义的)
index => "order"
document_id => "%{order_id}"
}
}
if [type]=="tb_role" {
elasticsearch {
#ESIP地址与端口
hosts => "localhost:9200"
#ES索引名称(自己定义的)
index => "role"
document_id => "%{id}"
}
}
}
3.执行命令
logstash -f 配置文件地址
以上是关于logstash通过mysql数据库多张表的主要内容,如果未能解决你的问题,请参考以下文章