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

相关推荐
aLTttY3 小时前
【Redis实战】分布式锁的N种实现方案对比与避坑指南
数据库·redis·分布式
小江的记录本13 小时前
【微服务与云原生架构】DevOps、CI/CD流水线、GitOps 系统性知识体系
分布式·后端·ci/cd·微服务·云原生·架构·devops
2603_9547083115 小时前
微电网混合控制架构:主从与对等控制的优势融合
分布式·安全·架构·能源·需求分析
zhangzeyuaaa15 小时前
Python多进程同步与共享内存完全指南:从Lock到分布式共享
开发语言·分布式·python
aini_lovee15 小时前
多智能体点对点转换的分布式模型预测控制(DMPC)
分布式
_F_y16 小时前
仿RabbitMQ实现消息队列-项目设计
分布式·rabbitmq
keep intensify18 小时前
MIT 6.824 lab3B/C
分布式·后端·golang
java1234_小锋18 小时前
RabbitMQ中有哪几种交换机类型?
分布式·rabbitmq
代码漫谈19 小时前
探索RabbitMQ集群:如何实现消息的高可用性和负载均衡
分布式·消息队列·rabbitmq·负载均衡
weisian1511 天前
Java并发编程--45-分布式一致性协议入门:Raft、Paxos与ZAB的核心思想
java·分布式·raft·paxos·zab