Kafka3.0 命令行操作

Kafka3.0 安装镜像下载

阿里云镜像

Kafka配置

在kafka2.8中就已经开始弃用外部的zookeeper依赖了,而在内部集成了高适配的zk
Kafka官网
内置的zk端口默认是2181,而kafka broker默认的端口是9092这里需要区分

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0

# A comma separated list of directories under which to store log files
log.dirs=/usr/local/kafka/datas

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=localhost:2181

kafka broker端口

############################# Producer Basics #############################

# list of brokers used for bootstrapping knowledge about the rest of the cluster
# format: host1:port1,host2:port2 ...
bootstrap.servers=localhost:9092

命令行基本使用

这里演示单机情况,kafka安装路径 /usr/local/kafka

  1. 首先启动kafka自带的zk
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
  1. 启动kafka
bin/kafka-server-start.sh -daemon config/server.properties
  1. 创建topic
bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic first --create --partitions 1 --replication-factor 1
Created topic first.
  1. 查看topic列表
bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic first --describe
Topic: first	TopicId: d1AD5F-2Sf-gBatOuEev6Q	PartitionCount: 1	ReplicationFactor: 1	Configs: segment.bytes=1073741824
	Topic: first	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
  1. 创建producer进程
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 -topic first

producer

  1. 创建consumer进程
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first

consumer

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值