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

相关推荐
ZENERGY-众壹1 小时前
50MW分布式VPP接入实战:调度中心要求的1分钟频率如何不卡死API
运维·服务器·分布式·光伏运维
富士康质检员张全蛋1 小时前
Kafka的操作 生产消息
分布式·kafka
ClickHouseDB3 小时前
推出 CostBench:一个用于数据仓库成本性能的开放基准
大数据·分布式·spark
9523618 小时前
Redis - 应用
数据库·redis·分布式·缓存
衣乌安、19 小时前
Redis 分布式锁与任务状态
数据库·redis·分布式
半夜修仙21 小时前
RabbitMQ的推模式和拉模式
java·分布式·中间件·rabbitmq·github·java-rabbitmq
buligbulig1 天前
Hadoop环境安装和集群创建
大数据·hadoop·分布式
橙臣程1 天前
集群、分布式与微服务介绍
分布式·微服务·架构
lailai04101 天前
表格自动化应用分析:功能边界与选型参考
分布式
Zhu7581 天前
在k8s环境部署Apache Kafka 集群架构,combined模式,无SSL配置
kafka·kubernetes·apache