目录
一、Nginx 安装配置
实验准备
es01 | 192.168.80.101 | ElasticSearch |
es02 | 192.168.80.102 | ElasticSearch |
es03 | 192.168.80.103 | ElasticSearch、Kibana |
nginx01 | 192.168.80.104 | nginx、Logstash |
NA | 192.168.80.100 | nginx、Filebeat |
初始化
systemctl disable --now firewalld
setenforce 0
vim /etc/selinux/config
SELINUX=disabled
cd /etc/yum.repos.d/
上传nginx.repo文件
yum install -y nginx
systemctl enable --now nginx
cd /usr/share/nginx/html
#准备测试页面
echo '<h1>this is web page</h1>' > test.html
echo '<h1>this is web2 page</h1>' > test1.html
二、Filebeat 安装配置
上传软件包 filebeat-6.7.2-linux-x86_64.tar.gz 到/opt目录
tar xf filebeat-6.7.2-linux-x86_64.tar.gz
mv filebeat-6.7.2-linux-x86_64 /usr/local/filebeat
cd /usr/local/filebeat
cp filebeat.yml filebeat.yml.bak
vim filebeat.yml
filebeat.inputs:
- type: log #指定 log 类型,从日志文件中读取消息
enabled: true #24行
paths:
- /var/log/nginx/access.log #28行指定监控的日志文件
- /var/log/nginx/error.log
tags: ["filebeat"] #设置索引标签
fields: #46行可以使用 fields 配置选项设置一些参数字段添加到 output 中
service_name: nginx
log_from: 192.168.80.100
--------------output-------------------
(全部注释掉)
----------------Logstash output---------------------
output.logstash: #162行
hosts: ["192.168.80.101:5044"] #164行指定 logstash 的 IP 和端口
三、Logstash 修改配置
cd /etc/logstash/conf.d
vim filebeat.conf
input {
beats {
port => "5044"
}
}
#filter {}
output {
elasticsearch {
hosts => ["192.168.80.102:9200", "192.168.80.103:9200", "192.168.80.104:9200"]
index => "nginx-%{+yyyy.MM.dd}"
}
}
logstash -t -f filebeat.conf #检查文件
四、Filebeat 启动配置
192.168.80.100
#启动 filebeat
./filebeat -e -c filebeat.yml
#-e:输出到标准输出,禁用syslog/文件输出
#-c:指定配置文件
192.168.80.101
#启动 logstash
logstash -f filebeat.conf
五、Kibana 验证
创建索引并配置
验证即可