首页 > 代码库 > LogStash如何通过jdbc 从mysql导入elasticsearch
LogStash如何通过jdbc 从mysql导入elasticsearch
input { stdin { } jdbc { # mysql jdbc connection string to our backup databse jdbc_connection_string => "jdbc:mysql://localhost:3306/userdb?useUnicode=true&characterEncoding=utf-8&useSSL=false" # the user we wish to excute our statement as jdbc_user => "user" jdbc_password => "pass" # the path to our downloaded jdbc driver jdbc_driver_library => "mysql-connector-java-5.1.40-bin.jar" # the name of the driver class for mysql jdbc_driver_class => "com.mysql.jdbc.Driver" jdbc_paging_enabled => "true" jdbc_page_size => "50000" statement_filepath => "mysqltestsql.sql" schedule => "* * * * *" type => "jdbc" use_column_value => true tracking_column => id last_run_metadata_path => "C:\logstash-5.2.0\bin\last_run_metadata_path\last_run_metadata_path" }}filter { json { source => "message" remove_field => ["message","_id"] }}output { elasticsearch { action => "index" hosts => ["http://localhost:9200"] index => "mysqltestdb2" #index => "user" workers => 1 } #stdout { #codec => rubydebug #codec => json_lines #}}
mysqltestsql.sql
select id, name from userinfo WHERE id > :sql_last_value
LogStash如何通过jdbc 从mysql导入elasticsearch
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。