Logstash5.6.5安装部署

1、从官网下载安装包
https://artifacts.elastic.co/downloads/logstash/logstash-5.6.5.zip
2、解压
3、定义logstash.conf,在bin目录新增一个logstash.conf文件,将mysql-connector-java-5.1.44.jar放在bin目录

input {
  stdin {
  }
  jdbc {
  # mysql jdbc connection string to our backup databse  后面的test对应mysql中的test数据库
  jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/test"
  # 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 => "mysql-connector-java-5.1.44.jar"
  # the name of the driver class for mysql
  jdbc_driver_class => "com.mysql.jdbc.Driver"
  jdbc_paging_enabled => "true"
  jdbc_page_size => "50000"
  jdbc_default_timezone => "Asia/Shanghai" 
  record_last_run => true
  use_column_value => true
  tracking_column => "createtime"
  last_run_metadata_path => "my_info_last"
#以下对应着要执行的sql的绝对路径。
  #statement_filepath => "jdbc-sql.sql"
  statement => "SELECT * FROM user_score where createtime > :**sql_last_value**"
#定时字段 各字段含义(由左至右)分、时、天、月、年,全部为*默认含义为每分钟都更新
  schedule => "* * * * *"
#设定ES索引类型
  type => "user_score"
  }
}

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

output {
  elasticsearch {
#ESIP地址与端口
  hosts => "192.168.103.190:9200"
#ES索引名称(自己定义的)
  index => "score"
#自增ID编号
  document_id => "%{id}"
  }
  stdout {
#以JSON格式输出
  codec => json_lines
  }
}

4、安装logstash-input-jdbc插件

D:\logstash-5.6.5\bin>logstash-plugin install logstash-input-jdbc

5、启动logstash

D:\logstash-5.6.5\bin>logstash -f logstash.conf

6、正常启动情况
Logstash5.6.5安装部署_第1张图片

你可能感兴趣的:(Logstash5.6.5安装部署)