码迷,mamicode.com
首页 > 数据库 > 详细

logstash通过mysql数据库多张表

时间:2020-10-19 22:59:20      阅读:35      评论:0      收藏:0      [点我收藏+]

标签:ssl   host   cte   from   enc   page   sea   数据库   arch   

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 配置文件地址

logstash通过mysql数据库多张表

标签:ssl   host   cte   from   enc   page   sea   数据库   arch   

原文地址:https://www.cnblogs.com/huangfeialllen/p/13841473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!