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

相关推荐
donk131415 小时前
React Native for OpenHarmony 实战:三方库 react-native-step-indicator 的鸿蒙化适配指南
分布式·react native·react.js·wpf·harmonyos
梅菲塔亚17 小时前
Ceph分布式存储
分布式·ceph
acrel719 小时前
Acrel-1000系列分布式光伏监控系统在湖北荆门一马光彩大市场屋顶光伏发电项目中应用
分布式·光伏并网
程序 代码狂人20 小时前
金融数仓体系与核心业务知识详解
大数据·分布式·spark
RobinXYuan20 小时前
【Kafka 源码手记】02 Kafka 的核心哲学:Everything Is A Log
kafka·源码阅读
java_nnnn1 天前
Redis 初识:从单体架构到分布式架构的演进
redis·分布式·架构
Sayai1 天前
Kafka 2.8→3.9.1 跨大版本升级实战:ZooKeeper 同步升级、数据目录迁移与回滚预案全流程
大数据·运维·分布式·zookeeper·kafka
敲上瘾1 天前
分布式系统——Redis哨兵:自动故障转移与选举原理
linux·数据库·redis·分布式·缓存·微服务
微三云 - 廖会灵 (私域系统开发)2 天前
供应链系统实战:多渠道订单聚合与分布式库存一致性方案总结
开发语言·分布式·php