kafka 集群搭建 & 常用命令

1、集群搭建:

<1> 将kafka 压缩包解压到某一目录

tar -zxvf kafka_2.12-3.5.1.tgz

<2> 修改节点配置文件

vim config/server.properties

broker.id=0

log.dirs=/tmp/kafka-logs

<3> 将安装好的kafka 分发到其他服务器

scp -r kafka_2.12-2.4.1/ xxx

<4>配置KAFKA_HOME环境变量

vim /etc/profile

export KAFKA_HOME=/home/abin/kafka_2.12-3.5.1

export PATH=:PATH:(KAFKA_HOME)

将profile分发到各节点

scp /etc/profile 服务器

source /etc/profile

<5>查看是否搭建成功

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

2、kafka 常用命令

zookeeper启动:nohup bin/zookeeper-server-start.sh config/zookeeper.properties

kafka启动:nohup bin/kafka-server-start.sh config/server.properties

jps 查看是否启动

创建主题:

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

topic分区扩容

kafka-topics.sh --zookeeper localhost:2181 --alter --topic test --partitions 4

删除topic

kafka-topics.sh --delete --zookeeper localhost:2181 localhost:9092 --topic test

查询topic 详细信息

kafka-topics.sh --topic event_topic --zookeeper localhost:2181 --describe

列出主题:

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

发送消息:

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

消费消息:

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

相关推荐
lsc_blog16 小时前
听到优化风声,先准备能由自己掌控的事
数据库·分布式·中间件·职场和发展·重构
Lansonli2 天前
大数据Spark(八十七):Spark-Submit 参数详解
大数据·分布式·spark
qq_452396232 天前
第二篇:《CommitLog + ConsumeQueue:一条日志解决 Kafka 多分区随机写的难题》
分布式·kafka
Alluxio3 天前
Alluxio + OCI:为 AI 工作负载实现亚毫秒访问延迟与可扩展吞吐
运维·数据库·人工智能·分布式·缓存·ai·语言模型
阿卡好可爱3 天前
Lua 热更新不生效:改完文件线上仍是旧逻辑,package.loaded 与 upvalue 重绑定详解
数据结构·分布式·后端·架构·lua
我不会起名字3224 天前
消费回调固定 return nil:错误传播与 Kafka 位点提交的区别
后端·mongodb·kafka·go·im·故障排查
qq_452396234 天前
第十篇:《Kafka 安全加固:SASL、SSL、ACL 与多租户隔离》
安全·kafka·ssl
用户3610588626125 天前
KafkaProducer 元数据管理:send() 卡住时,它在等什么
kafka
方方洛5 天前
ray教程-28-附录G-CICD与Slurm与云上调度
人工智能·分布式·机器学习