单机版kafka安装

1、下载

Apache Kafka

 2、修改配置

vim zookeeper.properties

vim server.properties

 

 

 3、运行zk

 bin/zookeeper-server-start.sh -daemon config/zookeeper.properties

./zookeeper-server-start.sh -daemon ../config/zookeeper.properties #启动zookeeper
./zookeeper-server-stop.sh #停止zookeeper

 4、运行kafa

bin/kafka-server-start.sh -daemon config/server.properties

./kafka-server-start.sh -daemon ../config/server.properties #启动kafka
./kafka-server-stop.sh #停止kafka

 5、测试

(1)创建主题

bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic iot_topic

(2)列出主题

bin/kafka-topics.sh --list --bootstrap-server localhost:9092

(3)生产者发消息

./kafka-console-producer.sh --broker-list localhost:9092 --topic iot_topic

(4)消费者接收消息

./kafka-console-consumer.sh --bootstrap-server localhost:9092  --topic iot_topic --from-beginning

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group iot_group

(5)查看消费组信息

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group iot_group

[root@localhost kafka]# bin/zookeeper-server-start.sh -daemon config/zookeeper.properties 
[root@localhost kafka]# bin/kafka-server-start.sh -daemon config/server.properties 
[root@localhost kafka]# bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic iot_topic
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
Created topic iot_topic.
[root@localhost kafka]# bin/kafka-topics.sh --list --bootstrap-server localhost:9092
iot_topic

#生产者发消息
[root@localhost kafka]# bin/kafka-console-producer.sh --broker-list localhost:9092 --topic iot_topic
>hah
>sdw
>1
>2
>3

#消费者收消息
[root@localhost kafka]# bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic iot_topic --group iot_group
hah
sdw
wuqing
1
2

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值