windows安装logstash-input-jdbc并使用其导入MMSQL数据

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.下载Microsoft JDBC Driver 6.0 for SQL Server(https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774)

windows安装logstash-input-jdbc并使用其导入MMSQL数据

解压文件:

windows安装logstash-input-jdbc并使用其导入MMSQL数据

C:/Elastic/logstash-6.0.0-beta2/lib下创建sqlserverdriver文件夹,并将对应的JDBC 驱动程序拷贝到该文件夹下。

5.在C:/Elastic/logstash-6.0.0-beta2/config下创建sqlserver.conf编码格式设置为ANSI,编辑内容:

input {
    jdbc {
        jdbc_driver_library => "D:/logstash/lib/sqlserverdriver/sqljdbc42.jar"
        jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        jdbc_connection_string => "jdbc:sqlserver://{自身IP地址}:1433;databaseName={数据库名称};"
        jdbc_user => "{数据库登录账号}"
        jdbc_password => "{数据库登录密码}"
        schedule => "* * * * *"
	jdbc_paging_enabled => "true"
	jdbc_page_size => "1000"
        jdbc_default_timezone => "Asia/Shanghai"
        statement => "SELECT * FROM merchants"
    }
}
filter {
    json {
        source => "message"
        remove_field => ["message"]
    }
}

output {
    elasticsearch {
        index => "checkin_new"
        document_type => "merchants"
        document_id => "%{id}"
        hosts => ["127.0.0.1:9200"]
    }
    stdout {
        codec => json_lines
    }
}

  

 6.在C:Elasticlogstash-6.0.0-beta2Shift+鼠标右键,选择在此处打开命令窗口(W)
  执行binlogstash -f configsqlserver.conf,开始数据导入