es同步mysql同步-logstash

1.下载es

https://www.elastic.co/downloads/elasticsearch

修改 config 下elasticsearch.yml   ip和端口等配置

2.下载kibana

https://www.elastic.co/downloads/kibana

修改 config 下kibana.yml   ip和端口es等配置

3.下载logstash

https://www.elastic.co/downloads/logstash

下载jar mysql-connector-java-5.1.47.jar

config下添加文件jdbc.conf

input {
    stdin {
    }
    jdbc {
      # mysql jdbc connection string to our backup databse
      jdbc_connection_string => "jdbc:mysql://localhost:3306/testguize"
      # the user we wish to excute our statement as
      jdbc_user => "chai"
      jdbc_password => "chai"
      # the path to our downloaded jdbc driver
      jdbc_driver_library => "E:\elasticsearch6.1\mysql-connector-java-5.1.26.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 => "select * from user"
      # statement_filepath => "F:\FullText\logstash-6.3.2\config\jdbc.sql"
      schedule => "* * * * *"
      type => "lxuser"
    }
}

filter {
    json {
        source => "message"
        remove_field => ["message"]
    }
}

output {
    elasticsearch {
        hosts => "192.168.0.61:9200"
        # port => "9200"
        # protocol => "http"
        index => "mysql"
        document_id => "%{id}"
        # cluster => "fulltext-application"
    }
    stdout {
        codec => json_lines
    }
}

4.启动es 

elasticsearch 下载目录bin目录下elasticsearch.bat

5. logstash bin目录下

执行命令 logstash.bat -f ..\config\jdbc.conf
6.启动 kibana 测试es连接
 

你可能感兴趣的:(es同步mysql同步-logstash)