ELK+FileBeat+Metricbeat+Nginx安装
注意:本文采用7.17.3版本
ELK安装
https://github.com/deviantony/docker-elk下载其压缩包放入到虚拟机中解压
这个ELK包是有付费功能的,取消的话可以看看他的README.md
cd /opt/software
unzip docker-elk-release-7.x.zip
cd /opt/software/docker-elk-release-7.x
# 启动
docker-compose up -d
# 查看是否启动成功
docker ps
curl http://localhost:9200 -u elastic:changeme
该ELK的密码在.env 文件内
将Kibana改为中文/opt/software/docker-elk-release-7.x/kibana/config文件夹下的kibana.yml
# 在末尾添加
i18n.locale: "zh-CN"
# 重启
docker restart docker-elk-release-7x_kibana
# 或者整个重启
docker-compose restart
Nginx安装
下载Nginx镜像
docker pull nginx
创建存储卷,便于 Nginx 和 Filebeat 容器共同挂载
docker volume create nginx-log-volume
启动 Nginx 容器,并且将存储卷映射到日志目录
docker run -d --name nginx -p 8080:80 -v nginx-log-volume:/var/log/nginx nginx
进入容器修改配置
docker exec -it nginx /bin/bash
由于容器环境下,默认的日志会输入到stdout,所以取消该设置并指定文件
unlink /var/log/nginx/access.log
unlink /var/log/nginx/error.log
touch /var/log/nginx/access.log /var/log/nginx/error.log
nginx -s reload
Filebeat安装
下载镜像
docker pull elastic/filebeat:7.17.3
启动镜像
临时启动
docker run -d --name=filebeat elastic/filebeat:7.17.3
拷贝数据文件
docker cp filebeat:/usr/share/filebeat /data/elk/
chmod 777 -R /data/elk/filebeat
chmod go-w /data/elk/filebeat/filebeat.yml
chmod go-w /data/elk/filebeat/modules.d/nginx.yml
编辑配置文件/data/elk/filebeat/filebeat.yml
# 收集系统日志
filebeat.inputs:
- type: log
enabled