ElasticSearch how to integrate with Mysql

前端 未结 5 893
长情又很酷
长情又很酷 2020-11-30 16:59

In one of my project i am planning to use ElasticSearch with mysql. I have successfully installed ElasticSearch. I am able to manage index in ES separately. but i don\'t kno

5条回答
  •  有刺的猬
    2020-11-30 17:56

    The logstash JDBC plugin will do the job:

    input {
      jdbc { 
        jdbc_connection_string => "jdbc:mysql://localhost:3306/testdb"
        jdbc_user => "root"
        jdbc_password => "factweavers"
        # The path to our downloaded jdbc driver
        jdbc_driver_library => "/home/comp/Downloads/mysql-connector-java-5.1.38.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        # our query
        schedule => "* * * *"
        statement => "SELECT" * FROM testtable where Date > :sql_last_value order by Date"
        use_column_value => true
        tracking_column => Date
    }
    
    output {
      stdout { codec => json_lines }
      elasticsearch {
      "hosts" => "localhost:9200"
      "index" => "test-migrate"
      "document_type" => "data"
      "document_id" => "%{personid}"
      }
    }
    

提交回复
热议问题