elasticsearch5.2.2 ik logstash5.2.2 搭建

来源:互联网 发布:js将base64转换成文件 编辑:程序博客网 时间:2024/05/17 14:29
elasticsearch5.2.2  安装  ik

https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.2.2/elasticsearch-analysis-ik-5.2.2.zip

1、直接到https://github.com/medcl/elasticsearch-analysis-ik/releases下载对应版本zip包

解压到elasticsearch的plugin目录下
unzip elasticsearch-analysis-ik-5.5.1.zip

2、使用elasticsearch-plugin命令安装
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.2.2/elasticsearch-analysis-ik-5.2.2.zip

重新启动elasticsearch
systemctl restart elasticsearch.service


logstash 配置 jdbc 到 es


logstash-5.2.2 jdbc install


1 下载 logstash-5.2.2

2 在bin install jdbc 插件

  logstash-plugin install logstash-input-jdbc


3 在bin 目录下 新间 jdbc_test 文件夹

  里面 新建 jdbc.conf  jdbc.sql 文件
  配置如下
  jdbc.sql 文件
  select * from domains where domains.id > :sql_last_value

  jdbc.conf 文件


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 => ""
  # the path to our downloaded jdbc driver
  jdbc_driver_library => "D:\soft\es\logstash-5.2.2\bin\jdbc_test\mysql-connector-java-5.1.40-bin.jar"
  # the name of the driver class for mysql
  jdbc_driver_class => "com.mysql.jdbc.Driver"
  jdbc_paging_enabled => "true"
  jdbc_page_size => "50000"
  record_last_run=>true
  use_column_value => true
  tracking_column => "id"
#以下对应着要执行的sql的绝对路径。
  statement_filepath => "D:\soft\es\logstash-5.2.2\bin\jdbc_test\jdbc2.sql"
#以下对应着要要保存的自定义字段的值。
  last_run_metadata_path=>"D:\soft\es\logstash-5.2.2\bin\jdbc_test\jdbc4"
#定时字段 各字段含义(由左至右)分、时、天、月、年,全部为*默认含义为每分钟都更新(测试结果,不同的话请留言指出)
  schedule => "* * * * *"
#设定ES索引类型
  type => "ad_type"
  }
}
filter {
    json {
        source => "message"
        remove_field => ["message"]
    }
}
output {
  elasticsearch {
  #ESIP地址与端口
  hosts => "127.0.0.1:9400"
  #ES索引名称(自己定义的)
  index => "ad"
  #自增ID编号 对应的 es  _id 唯一主键
  document_id => "%{id}"
  }
  stdout {
#以JSON格式输出
codec => json_lines
  }

}


4 下载  mysql-connector-java-5.1.40-bin.jar  改jar 需要下载,然后上面配置指向改jar 所在路径
5 执行 ./logstash.bat -f ./jdbc_test/jdbc.conf

./logstash.bat -f ./jdbc_test/jdbc2.conf

elasticsearch curl 命令

curl -XGET 'localhost:9400/_cat/health?v'
curl -XGET 'localhost:9400/_cat/indices?v'
curl -XGET http://127.0.0.1:9400/ad/ad_type/1?_source 
原创粉丝点击