windows安装logstash-input-jdbc

1.安装logstash


2.修改logstash 文件夹下Gemfile文件

将source改为:https://gems.ruby-china.org


3.进入bin目录

执行logstash-plugin install logstash-input-jdbc

出现如下信息

Validating logstash-input-jdbc
Installing logstash-input-jdbc
Installation successful

表示安装成功


4.在bin目录中新建lib目录,放入mysql-connector-java-5.1.30.jar包


5.在bin目录中新建jdbc.sql文件


加入如下内容

SELECT * from cas_user


6.修改logstash文件夹下config\logstash.conf文件
改成如下配置:
input {
    stdin {
    }
    jdbc {
      # mysql jdbc connection string to our backup databse
      jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/exam"
      # the user we wish to excute our statement as
      jdbc_user => "root"
      jdbc_password => "123456"
      # the path to our downloaded jdbc driver
      jdbc_driver_library => "lib\mysql-connector-java-5.1.30.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 => "jdbc.sql"
      schedule => "* * * * *"
      type => "jdbc"
    }
}
filter {
    json {
        source => "message"
        remove_field => ["message"]
    }
}
output {
    elasticsearch {
        hosts => ["127.0.0.1:9200"]
        index => "mysql01"
        document_id => "%{id}"
    }
    stdout {
        codec => json_lines
    }

}


7.进入bin目录,执行如下命令

logstash.bat -f  ../config/logstash.conf

出现如下界面:

windows安装logstash-input-jdbc_第1张图片

代表启动成功,试着给对应表新增数据试试吧!

你可能感兴趣的:(windows安装logstash-input-jdbc)