运行环境
系统:Centos7
ELK版本:6.7版本(2019.4月)
安装过程
省略…
官网下载安装包即可
下载地址:https://www.elastic.co/downloads/
Elasticsearch
- 新建一个elk账号,默认不允许root用户运行
[root@node1 ~]# useradd elkuser
[root@node1 ~]# chown -R elkuser:elkuser /yourpath/elasticsearch
- 修改系统参数
[root@node1 ~]# vim /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
[root@node1 ~]# vim /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
修改为
* soft nproc 4086
[root@node1 ~]#vim /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
最后重启系统
- 修改elasticsearch配置
[elkuser@node1 elasticsearch]# vim /yourpath/elasticsearch/config/elasticsearch.yml
添加如下内容:
#配置默认data和log目录
path.data: /yourpath/elasticsearch/data
path.logs: /yourpath/elasticsearch/logs
#允许外网访问,自己按需配置
network.host: 0.0.0.0
#允许跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
- 启动elasticsearch
[elkuser@node1 elasticsearch]# cd /yourpath/elasticsearch
[elkuser@node1 elasticsearch]# ./bin/elasticsearch -d
如果遇到报错,查看elasticsearch的log目录下elasticsearch.log文件,再看看error提示什么,解决相应的问题。
记得关闭防火墙或者放行elasticsearch默认端口9200
如果你的系统配置内存不足4GB,那么则要通过下面的命令来启动elasticsearch
[elkuser@node1 elasticsearch]# cd /yourpath/elasticsearch/bin
[elkuser@CentOS-01 elasticsearch]# ES_JAVA_OPTS="-Xms512m -Xmx512m" ./elasticsearch -d
Logstash
- 新增一个logstash的配置,保存为
logstash/config/test.conf
input {
file {
path => []
codec => json {
charset => "UTF-8"
}
}
}
output {
elasticsearch {
hosts => "node1"
index => "logstash-%{+YYYY.MM.dd}"
document_type => "test"
}
}
- 启动logstash
以test.conf
为默认配置文件在后台启动logstash,将运行日志输出到run.log
中,可以及时查看报错。
[root@logstash-svr logstash]# nohup ./bin/logstash -f config/test.conf &> run.log &
Kibana
-
kibana汉化
kibana官方是不带中文的,为了便于平时的使用,可以使用第三方汉化插件
项目地址:https://github.com/anbai-inc/Kibana_Hanization
汉化前记得备份文件! -
启动kibana,
0.0.0.0
允许外网ip访问,自己按需修改!
[root@kibana-svr kibana-6.7.1]# nohup ./bin/kibana -H 0.0.0.0 &> run.log &