arterhuo / blog

1 stars 1 forks source link

kafka学习笔记 #4

Open huoarter opened 5 years ago

huoarter commented 5 years ago

注意: kafka一个分区只能分配给一个group中的一个consumer,所以有60个分区,最多可以起60个consumer

[root@xg-ops-elk-kafka-1 kafka]# cat topics-to-move.json {"topics": [{"topic": "java-standard-application-log"}], "version":1 }

- 生成推荐分布,也可以手动编辑,保存在java_balance_topics.json 例如:

{"version":1,"partitions":[{"topic":"java-standard-application-log","partition":30,"replicas":[2]},{"topic":"java-standard-application-log","partition":2,"replicas":[4]},{"topic":"java-standard-application-log","partition":40,"replicas":[2]},....


- 进行重新分配:

bin/kafka-reassign-partitions.sh --zookeeper xg-ops-elk-kafka-1:2181,xg-ops-elk-kafka-2:2181,xg-ops-elk-kafka-3:2181 --reassignment-json-file java_balance_topics.json --execute

- 验证分配进度:

bin/kafka-reassign-partitions.sh --zookeeper xg-ops-elk-kafka-1:2181,xg-ops-elk-kafka-2:2181,xg-ops-elk-kafka-3:2181 --reassignment-json-file java_balance_topics.json --verify


**压测数据:**

sh kafka-producer-perf-test.sh --topic ertao_test --num-records 5000000 --record-size 512 --throughput 1000000 --producer-props bootstrap.servers=xg-ops-elk-ngxkf-1:9092,xg-ops-elk-ngxkf-1:9092 acks=all retries=2 linger.ms=1 sh kafka-producer-perf-test.sh --topic ertao_test --num-records 5000000 --record-size 512 --throughput 100 0000 --producer-props bootstrap.servers=xg-ops-elk-ngxkf-1:9092,xg-ops-elk-ngxkf-1:9092 acks=all retries=2 linger.ms=1

sh kafka-producer-perf-test.sh --topic ertao_test --num-records 5000000 --record-size 512 --throughput 1000000 --producer-props bootstrap.servers=xg-ops-elk-ngxkf-1:9092,xg-ops-elk-ngxkf-1:9092 acks=1 retries=2 linger.ms=1

sh kafka-producer-perf-test.sh --topic ertao_test --num-records 5000000 --record-size 512 --throughput 1000000 --producer-props bootstrap.servers=xg-ops-elk-ngxkf-1:9092,xg-ops-elk-ngxkf-1:9092 acks=0 retries=2 linger.ms=1

./kafka-consumer-perf-test.sh --zookeeper localhost:2181 --messages 50000000 --topic ertao_test --threads 1