1、ELK+IK版本6.4.3
2、解压上面截图4个压缩包,在\elasticsearch-6.4.3\plugins目录下新建analysis-ik把kibana-6.4.3-windows-x86_64文件夹下文件拷贝进去。
3、修改配置文件elasticsearch-6.4.3\config\elasticsearch.yml
cluster.name: elasticsearch
network.host: 0.0.0.0
修改配置文件elasticsearch-6.4.3\config\ jvm.options防止日志中文乱码
-Dfile.encoding=GBK
启动ES 执行elasticsearch-6.4.3\bin\elasticsearch.bat
4、修改springboot对应的pom文件增加包依赖
修改配置文件src/main/resources/application.yml
data:
elasticsearch:
cluster-name: elasticsearch
cluster-nodes: 127.0.0.1:9300
5、使用logstash同步数据到ES
新建logstash-6.4.3\bin\oracle.conf
文件内容如下:
input {
jdbc {
jdbc_connection_string => "jdbc:oracle:thin:@127.0.0.1:1521:ORCL"
jdbc_user => "username"
jdbc_password => "password"
jdbc_driver_library => "F:\jdbc\lib\ojdbc6.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
statement_filepath => "F:\ELK\logstash-6.4.3\sql\oracle_all.sql"
schedule => "* * * * *"
record_last_run => true
use_column_value => true
tracking_column => "time"
tracking_column_type => "numeric"
last_run_metadata_path => "F:\ELK\logstash-6.4.3\sql\oracle_last_time.txt"
clean_run => false
lowercase_column_names => true
}
}
filter {
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "xxxx"
#配置模板文件
manage_template=>true
template_overwrite => true
template => "F:\ELK\logstash-6.4.3\templete\template03.json"
}
stdout {
codec => json_lines
}
}
再建一个启动脚本 logstash-6.4.3\bin\run_oracle.bat内容如下
logstash -f oracle.conf
新建logstash-6.4.3\sql\oracle_all.sql内容如下:
select * from (select * from XXXXX order by time) where time > :sql_last_value
新建个空文件 logstash-6.4.3\sql\oracle_last_time.txt为了记录sql_last_value
新建模板文件logstash-6.4.3\templete\ template03.json指定分词内容如下
{
"template": "*",
"order":1,
"version" : 10001,
"settings" : {
"index.refresh_interval" : "5s",
"number_of_shards": 1
},
"mappings":{
"doc": {
"properties": {
"depname": {
"type": "text",
"analyzer": "ik_max_word"
},
"id": {
"type": "keyword"
}
}
}
}
}
启动 logstash 执行logstash-6.4.3\bin\run_oracle.bat文件
6、修改kibana-6.4.3-windows-x86_64\config\ kibana.yml配置文件elasticsearch.url为es服务的地址
启动kibana执行以下文件kibana-6.4.3-windows-x86_64\bin\kibana.bat
创建索引
查看数据