#コピペで即動くKafka速習
JDKインストール
apt-get install java-1.8.0-openjdk-devel
Kafka Brokerインストール
wget http://ftp.tsukuba.wide.ad.jp/software/apache/kafka/2.8.1/kafka_2.12-2.8.1.tgz
tar -xvf kafka_2.12-2.8.1.tgz
mv kafka_2.12-2.8.1 /usr/local/
cd /usr/local/kafka_2.12-2.8.1
Zookeeper起動
./bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties
Broker起動
./kafka-server-start.sh ../config/server.properties
Topic作成
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
./kafka-topics.sh --list --zookeeper localhost:2181
test
Topicにメッセージ生成
./kafka-console-producer.sh --broker-list localhost:9092 --topic test
>Hellow World!
>How has COVID-19 affected your country?
Topicからメッセージ取得
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
Hellow World!
How has COVID-19 affected your country?