当前位置:   article > 正文

kafka 集群搭建 & 常用命令_windows系统中kafka创建多个集群的命令

windows系统中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

zookeeper 连接配置

zookeeper.connect=节点1:2181,节点2:2181,节点3:2181

<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

./kafka-topics.sh --bootstrap-server localhost:9092 --alter --topic test --
partitions 3

删除topic

<1>kafka-topics.sh --delete --zookeeper  localhost:2181 localhost:9092 --topic test

<2>./kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic test (高版本不依赖zookeeper)

查询topic 详细信息

./kafka-topics.sh --describe --topic test --bootstrap-server localhost:9092

列出主题:

./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

3、kafka 的基准测试

./kafka-producer-perf-test.sh --topic test --num-record 500000 --throughput -1 --record-size 1000 --producer-props bootstrap.servers=localhost:9092 acks=1

--topic    topic 的名字

--num-records  指定总共生产数据量(默认5000W)

--throughput     指定吞吐量,限流,-1不指定

--record-size  record 数据大小(字节)

--producer-props bootstrap.servers=localhost:9092 acks=1  指定kafka 集群地址,ACK模式

测试消费的效率

 ./kafka-consumer-perf-test.sh --broker-list localhost:9092 --topic test --fetch-size 1048576 --messages 500000

--fetch-size  每次要拉去的数据大小

--messages  总共要消费的消息个数

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/400274
推荐阅读
相关标签
  

闽ICP备14008679号