数据库
首页 > 数据库> > logstash通过mysql数据库多张表

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:\soft\softinstall\apache-maven-3.3.9\resp\mysql\mysql-connector-java\8.0.16\mysql-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:\soft\softinstall\apache-maven-3.3.9\resp\mysql\mysql-connector-java\8.0.16\mysql-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 配置文件地址

标签:jdbc,true,张表,id,mysql,order,tb,logstash
来源: https://www.cnblogs.com/huangfeialllen/p/13841473.html