实验前准备
Node1节点(至少2核4G内存):192.168.188.15,Elasticsearch、Kibana
Node2节点(至少2核4G内存):192.168.188.16,Elasticsearch
Apache节点:192.168.188.14,Logstash、Apache
客户端:192.168.188.1(本机win11)
关闭防火墙
systemctl stop firewalld
setenforce 0
export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$PATH
input {
????file {
??????????path => "/var/log/messages" ??# 收集的日志位置
??????????type => "system" ????????????# 类型
??????????start_position => "beginning" ??# 开始位置为“开始”,也就是从头收集
????}
}
output {
????elasticsearch {
??????????hosts => ["192.168.188.15:9200"] ?# 指定elasticsearch的地址和端口
??????????index => "system-%{+YYYY.MM.dd}" ?# 索引格式system-后面加日期年月日
????}
}
input {
????file {
??????????path => "/etc/httpd/logs/access_log"
??????????type => "access"
??????????start_position => "beginning"
????}
????file {
??????????path => "/etc/httpd/logs/error_log"
??????????type => "error"
??????????start_position => "beginning"
????}
}
output {
????if [type] == "access" {
??????????elasticsearch {
??????????????hosts => ["192.168.188.15:9200"]
??????????????index => "apache_access-%{+YYYY.MM.dd}"
??????????}
????}
????if [type] == "error" {
??????????elasticsearch {
??????????????hosts => ["192.168.188.15:9200"]
??????????????index => "apache_error-%{+YYYY.MM.dd}"
??????????}
????}
}