ELK 6.4.3 OSS版本安裝配置
阿新 • • 發佈:2018-11-16
OSS版本是遵守Apache 2.0 licensed
的,屬於開源專案。
Elasticsearch OSS 倒排索引服務
Elasticsearch OSS 6.4.3 下載地址:
https://www.elastic.co/downloads/past-releases/elasticsearch-oss-6-4-3
解壓修改配置檔案:
# 資料檔案目錄 path.data: /data/disk/data/elasticsearch # 日誌檔案目錄 path.logs: /data/disk/log/elasticsearch # 關閉記憶體鎖定,不關的話,centos6下報錯。 bootstrap.memory_lock: false # 關閉系統呼叫過濾器,不關的話,centos6下報錯。 bootstrap.system_call_filter: false # 網路地址 network.host: 0.0.0.0 # 埠號 http.port: 9200
切換到非root
下su ekl
,
執行bin/elasticsearch
。
檢視結果:
curl http://localhost:9200/
elasticsearch analysis ik 分詞外掛
elasticsearch-analysis-ik 下載地址:
https://github.com/medcl/elasticsearch-analysis-ik/releases
安裝:
新建ik目錄,並解壓到ik目錄
mkdir your-es-root/plugins/ik unzip elasticsearch-analysis-ik-6.4.3.zip -d your-es-root/plugins/ik
新建索引:
curl -XPUT http://localhost:9200/index
新建對映
curl -XPOST http://localhost:9200/index/doc/_mapping -H 'Content-Type:application/json' -d'
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}'
Kibana OSS 視覺化開發工具
Kibana OSS 6.4.3 下載地址:
https://www.elastic.co/downloads/past-releases/kibana-oss-6-4-3
設定elasticsearch.url
到es:
執行bin/kibana
。
就可以在http://localhost:5601
看到介面了。
Logstash OSS 同步mysql到ES
Logstash OSS 6.4.3 下載地址:
https://www.elastic.co/downloads/past-releases/logstash-oss-6-4-3
配置一個檔案
input {
jdbc {
jdbc_driver_library => "mysql-connector-java-5.1.33-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_user => "user"
jdbc_password=> "password"
jdbc_connection_string => "jdbc:mysql://192.168.0.100:3306/db"
jdbc_validate_connection => "true"
schedule => "* * * * *"
use_column_value => true
tracking_column => "id"
last_run_metadata_path => "/data/.logstash_shandian_last_run"
statement => "SELECT a.id, a.title, a.keywords, d.content FROM table_article a JOIN table_data d ON a.id=d.id WHERE a.id > :sql_last_value AND a.status=100 ORDER BY id ASC"
jdbc_paging_enabled =>true
jdbc_page_size => 10000
}
}
filter {
date {
match => ["addline", "yyyy-MM-dd HH:mm:ss,SSS", "UNIX"]
target => "@timestamp"
locale => "cn"
}
}
output {
elasticsearch {
hosts => ["http://192.168.0.200:9200"]
index => "suoyin"
document_id => "%{id}"
}
stdout {
codec => line {
format => "suoyin: %{id} %{title}"
}
}
}
執行
bin/logstash -f logstash.conf