1,在官網下載filebeat
官網下載地址:
https://www.elastic.co/cn/downloadsapache
2,下載kafka
下載地址:
http://archive.apache.org/dist/kafka/bootstrap
3,下載完kafka以後,直接解壓便可
wget -c http://archive.apache.org/dist/kafka/2.1.1/kafka_2.11-2.1.1.tgz
tar -xf kafka-2.1.1-src.tg併發
4,kafka經常使用命令介紹
進入kafka目錄
cd kafka_2.11-2.1.1ide
啓動zookeeper
./bin/zookeeper-server-start.sh ./config/zookeeper.properties &測試
啓動kafka
./bin/kafka-server-start.sh ./config/server.properties &日誌
建立topic
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
列出topic
./bin/kafka-topics.sh --list --zookeeper localhost:2181server
啓動生產者併發送消息
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testblog
開啓另一個終端,啓動消費者接受消息
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginningget
效果圖以下:
生產者:
消費者:kafka
5,測試成功,如今咱們配置filebeat的配置文件
filebeat.inputs:
6,啓動filebeat並查看控制檯輸出
7,查看kafka是否接受到filebeat收集到的日誌信息
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning