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

相关推荐
Cachel wood9 天前
Spark教程6:Spark 底层执行原理详解
大数据·数据库·分布式·计算机网络·spark
找不到、了9 天前
kafka消费的模式及消息积压处理方案
java·kafka
超级小忍9 天前
Spring Boot 集成 Apache Kafka 实战指南
spring boot·kafka·apache
Ting-yu9 天前
零基础学习RabbitMQ(1)--概述
分布式·学习·rabbitmq
寒山李白9 天前
分布式ID生成方式及优缺点详解
数据库·分布式·分布式id生成方式
acrel158215962219 天前
光伏电站 “智慧大脑”:安科瑞 Acrel-1000DP 分布式监控系统技术解析
分布式·分布式光伏·安科瑞电气
Cachel wood10 天前
Spark教程1:Spark基础介绍
大数据·数据库·数据仓库·分布式·计算机网络·spark
沉着的码农10 天前
【分布式】Redisson滑动窗口限流器原理
java·redis·分布式·redisson
小葛呀10 天前
在大数据求职面试中如何回答分布式协调与数据挖掘问题
大数据·分布式·机器学习·面试·数据挖掘·互联网·技术栈
阳光下是个孩子10 天前
基于 Spark 实现 COS 海量数据处理
大数据·分布式·spark