环境准备

注:由于Logstash的运行依赖于Java环境, 而Logstash 1.5以上版本不低于java 1.7,因此推荐使用最新版本的Java。因为我们只需要Java的运行环境,所以可以只安装JRE,不过这里我依然使用JDK

1.1 平台环境:

  • OS: Amazon Linux 2
软件节点名ip
es,logstash,elasticsearch-head,kibananode-master01172.28.254.221
esnode-master02172.28.254.27
esnode-master03172.28.253.227

1.2 软件清单

软件安装路径配置文件端口访问地址
elasticsearch-7.17.3/usr/share/elasticsearch/etc/elasticsearch9200/tcp 9300/tcphttp://localhost:9200
elasticsearch-head(可选)/opt/elasticsearch-head-9100/tcphttp://localhost:9100
logstash-7.17.3/usr/share/logstash/etc/logstash5044/tcp 5045/tcp-
kibana-7.17.3/usr/share/kibana/etc/kibana5601/tcphttp://localhost:5601
filebeat-7.17.3(应用端)/usr/share/filebeat/etc/filebeat
metricbeat-7.17.3(应用端-可选)/usr/share/metricbeat/etc/metricbeat
kafka_2.12-3.1.0/usr/local/kafka01

1.3 安装准备

#配置iptables,保证内网之间可以互通
[root@Elk_Server]# iptables -F;iptables -I INPUT -s 172.28.0.0/16 -j ACCEPT
[root@Elk_Server]# service iptables save;service iptables restart   
#关闭selinux
[root@Elk_Server]# setenforce 0  
[root@Elk_Server]# vim /etc/sysconfig/selinux 
SELINUX=disabled

1.4 时间同步

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum install ntpdate -y;ntpdate time.windows.com
echo '01 00 * * * ntpdate time.windows.com' >>/etc/crontab

1.5 安装JAVA

1.8.0_151, 请见 http://qiangsh.blog.51cto.com/3510397/1771748

1.6 配置yum源

#导入公钥
[root@Elk_Server ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

[root@Elk_Server ~]# cat > /etc/yum.repos.d/elastic.repo <<EOF
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

[kibana-7.x]
name=Kibana repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

[logstash-7.x]
name=Elastic repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

#安装ELK
#yum --disablerepo=\* --enablerepo=elasticsearch install -y elasticsearch logstash kibana

安装Elasticsearch

安装步骤,请参考:https://blog.51cto.com/qiangsh/5320167

安装Kafka集群

安装步骤,请参考:https://blog.51cto.com/qiangsh/4738798

  • 创建测试日志Topic
    cd /usr/local/kafka01/bin
    ./kafka-topics.sh --create --bootstrap-server "172.28.254.221:9092,172.28.254.27:9092,172.28.253.227:9092" --replication-factor 1 --partitions 8 --topic test-log

安装Filebeat(应用服务器上安装)

  • 在要监控的每个系统上安装 Filebeat
  • 指定日志文件的位置

安装步骤,请参考:https://blog.51cto.com/qiangsh/5337463

安装Logstash:

安装步骤,请参考:https://blog.51cto.com/qiangsh/5337475

安装Kibana

安装步骤,请参考:https://blog.51cto.com/qiangsh/5348515