Kafka3.0 安装镜像下载
Kafka配置
在kafka2.8中就已经开始弃用外部的zookeeper依赖了,而在内部集成了高适配的zk

内置的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
- 首先启动kafka自带的zk
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
- 启动kafka
bin/kafka-server-start.sh -daemon config/server.properties
- 创建topic
bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic first --create --partitions 1 --replication-factor 1
Created topic first.
- 查看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
- 创建producer进程
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 -topic first

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

2941

被折叠的 条评论
为什么被折叠?



