文章目录
- 一、软件下载
- 1. zookeeper
- 2. kafka
- 二、安装与启动
- 2.1. jdk
- 2.2. zookeeper
- 2.3. kafka
- 三、 kafka 基本演示
一、软件下载
1. zookeeper
http://archive.apache.org/dist/zookeeper/zookeeper-3.5.7/apache-zookeeper-3.5.7-bin.tar.gz
2. kafka
https://archive.apache.org/dist/kafka/2.4.0/kafka_2.11-2.4.0.tgz
二、安装与启动
2.1. jdk
https://blog.csdn.net/weixin_40816738/article/details/103435776
2.2. zookeeper
cd /opt/spftware
tar -zxf apache-zookeeper-3.5.7-bin.tar.gz -C /opt/install
cd /opt/install
mv apache-zookeeper-3.5.7-bin zookeeper-3.5.7
cd zookeeper-3.5.7/conf
cp zoo_sample.cfg zoo.cfgcd zookeeper-3.5.7/bin
./zkServer.sh startps -ef |grep zookeeper
2.3. kafka
tar -zxf kafka_2.11-2.4.0.tgz -C /opt/install
vim /opt/install/kafka_2.11-2.4.0/config
vim server.properties修改以下2处:
listeners
advertised.listeners
三、 kafka 基本演示
1、启动Kafka
bin/kafka-server-start.sh config/server.properties &2、停止Kafka
bin/kafka-server-stop.sh3、创建Topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic gblfy-topic4、查看已经创建的Topic信息
bin/kafka-topics.sh --list --zookeeper localhost:21815、发送消息
bin/kafka-console-producer.sh --broker-list 192.168.60.128:9092 --topic gblfy-topic6、接收消息
bin/kafka-console-consumer.sh --bootstrap-server 192.168.60.128:9092 --topic gblfy-topic --from-beginning{"orderId":"002","price":"80"}