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

相关推荐
weixin_453965004 分钟前
[单master节点k8s部署]31.ceph分布式存储(二)
分布式·ceph·kubernetes
坎坎坷坷.14 分钟前
分布式理论:拜占庭将军问题
分布式
极客先躯6 小时前
高级java每日一道面试题-2024年10月3日-分布式篇-分布式系统中的容错策略都有哪些?
java·分布式·版本控制·共识算法·超时重试·心跳检测·容错策略
niu_sama7 小时前
仿RabbitMQ实现消息队列三种主题的调试及源码
分布式·rabbitmq
鸡c7 小时前
rabbitMq------客户端模块
分布式·rabbitmq·ruby
猿java8 小时前
使用 Kafka面临的挑战
java·后端·kafka
Dylanioucn8 小时前
【分布式微服务云原生】探索Redis:数据结构的艺术与科学
数据结构·redis·分布式·缓存·中间件
路上^_^8 小时前
00_概览_kafka
分布式·kafka
极客先躯15 小时前
Hadoop krb5.conf 配置详解
大数据·hadoop·分布式·kerberos·krb5.conf·认证系统
CopyLower16 小时前
Kafka 消费者状态及高水位(High Watermark)详解
分布式·kafka