zoukankan      html  css  js  c++  java
  • 使用logstash同步mysql 多表数据到ElasticSearch实践

    参考样式即可,具体使用配置参数根据实际情况而定

    input {  
        jdbc {  
          jdbc_connection_string => "jdbc:mysql://localhost/数据库名"  
          jdbc_user => "root"  
          jdbc_password => "password"  
          jdbc_driver_library => "mysql-connector-java-5.1.45-bin.jar所在位置"  
          jdbc_driver_class => "com.mysql.jdbc.Driver"
          codec => plain {charset => "UTF-8"}
          record_last_run => true
          jdbc_paging_enabled => "true"  
          jdbc_page_size => "1000"  
          statement => "sql statement"   
          schedule => "* * * * *"  
          type => "数据库表名1"  
          tags => "数据库表名1"
        }
        jdbc {  
          jdbc_connection_string => "jdbc:mysql://localhost/数据库名"  
          jdbc_user => "root"  
          jdbc_password => "password"  
          jdbc_driver_library => "mysql-connector-java-5.1.45-bin.jar所在位置"  
          jdbc_driver_class => "com.mysql.jdbc.Driver"
          codec => plain {charset => "UTF-8"}
          record_last_run => true
          jdbc_paging_enabled => "true"  
          jdbc_page_size => "1000"  
          statement => "sql statement"   
          schedule => "* * * * *"  
          type => "数据库表名2"
          tags => "数据库表名2"
        }
    }  
    
    filter {  
        json {  
            source => "message"  
            remove_field => ["message"]  
        }  
    }  
    
    output {  
        if [type] == "数据库表名1"{
            elasticsearch {
                hosts => ["els的host地址"]  
                index => "数据库表名1对应的els的index"  
                document_id => "%{唯一id}"
            }
        }
        if [type] == "数据库表名2"{
            elasticsearch {
                hosts => ["els的host地址"]  
                index => "数据库表名2对应的els的index"  
                document_id => "%{唯一id}"
            }
        }
        stdout {   
            codec => json_lines  
        }  
    }  
    
  • 相关阅读:
    单例模式的五种实现模式
    JAVA基础语法
    买卖股票的最佳时机 III
    leetcode 正则表达式 (动态规划)
    leetcode LRU缓存机制(list+unordered_map)详细解析
    leetcode 下一个排列(C++,STL源码解析)
    leetcode 编辑距离(动态规划)
    leetcode 字典序排数
    leetcode 字典序第K小数字
    leetcode 有效的括号(栈模拟)
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/12859292.html
Copyright © 2011-2022 走看看