一、安装JAVA环境
在Oracle官网获取最新版的Java版本,官网:http://www.oracle.com/
安装完成后,配置JAVA_HOME和JRE_HOME。
二、下载安装ELK
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.12.zip
https://artifacts.elastic.co/downloads/logstash/logstash-5.6.12.zip
https://artifacts.elastic.co/downloads/kibana/kibana-5.6.12-windows-x64.zip
注意需要jdk8环境
三、修改配置
3.1.编辑ES配置文件:
// E:/elk/elasticsearch-5.6.12/config/elasticsearch.yml
network.host:0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-credentials: true
node.master: true
node.data: true
3.2.新建Logstash日志分析配置文件:
// E:\elk\logstash-5.6.12\config\logstash.conf
input {
file {
path => "/data/logs/test.log"
}
}
output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "test-logstash-%{+YYYY.MM.dd}"
}
stdout {
codec => json_lines
}
}
3.3.编辑Kibana配置文件:
// E:/elk/kibana-5.6.12-windows-x86/config/kibana.yml
server.port: 5601
server.host: 127.0.0.1
elasticsearch.url: "http://127.0.0.1:9200"
四、启动
//启动ES
elasticsearch.bat
//启动Logstash
logstash.bat -f ../config/logstash.conf
//启动kibana
kibana.bat
五、验证
curl -XGET http://127.0.0.1:9200/
curl -XGET "http://127.0.0.1:9200/_search" -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}}'
或浏览器分别访问
es: http://127.0.0.1:9200/
kibana: http://127.0.0.1:5601/
六、ES支持中文查询
```shell
elasticsearch-analysis-ik下载地址:
https://github.com/medcl/elasticsearch-analysis-ik/releases
下载elasticsearch-analysis-ik-5.6.12.zip解压到 elasticsearch-5.6.12\plugins\ik目录下
然后重启elasticsearch
验证
GET _search
{
"query": {
"match": {
"message": "中华"
}
}
}
七、elasticsearch-head安装
elasticsearch-head是一个用于管理Elasticsearch的web前端插件
https://github.com/mobz/elasticsearch-head
运行环境准备NodeJS,Grunt
npm install -g grunt-cli
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
7.1 修改elasticsearch.yml,增加跨域的配置(需要重启es才能生效)
http.cors.enabled: true
http.cors.allow-origin: "*"
7.2 编辑elasticsearch-head/Gruntfile.js,修改服务器监听地址,connect节点增加hostname属性,将其值设置为*
connect: {
server: {
options: {
hostname:'*',
port: 9100,
base: '.',
keepalive: true
}
}
}
7.2 编辑elasticsearch-head/_site/app.js,
es地址http://127.0.0.1:9200/
7.3 启动
npm run start
浏览器打开http://127.0.0.1:9100/