v3.1.x将彻底移除kafka

Kafka无Zookeeper启动

  1. #!/bin/bash
  2. #注意3.0属于测试版
  3. basePath=/www/kafka_2.13-3.0.0
  4. kraftPath=/tmp/kraft-combined-logs
  5. if [[ ! -d "$kraftPath" ]]; then
  6. echo "Kafka 初始化Kraft"
  7. uuid=$($basePath/bin/kafka-storage.sh random-uuid)
  8. echo "$uuid"
  9. $basePath/bin/kafka-storage.sh format -t $uuid -c $basePath/config/kraft/server.properties
  10. else
  11. echo "Kafka 已使用Kraft"
  12. fi
  13. $basePath/bin/kafka-server-start.sh -daemon $basePath/config/kraft/server.properties

本地方式

  1. bin/zookeeper-server-start.sh config/zookeeper.properties
  2. bin/kafka-server-start.sh config/server.properties

Docker

docker pull hyperledger/fabric-kafka
docker pull hyperledger/fabric-zookeeper

docker network create app-kafka —driver bridge
docker run -d —name zookeeper-server —network app-kafka bitnami/zookeeper:latest
docker run -d —name kafka-server —network app-kafka -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 bitnami/kafka:latest

docker run -d —name zookeeper-server -p 2181:2181 -e “ALLOW_ANONYMOUS_LOGIN=yes” bitnami/zookeeper:latest
docker run -d —name kafka-server -p 9092:9092 -e “KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181” -e “ALLOW_PLAINTEXT_LISTENER=yes” bitnami/kafka:latest

kafka-v1.0.x

  1. ## 查看全部消费组
  2. ./bin/kafka-consumer-groups.sh --list --bootstrap-server 127.0.0.1:9092
  3. # 使用Zookeeper进行连接使用如下命令
  4. ./bin/kafka-consumer-groups.sh --list --zookeeper localhost:2181
  5. ## 查看消费组详情
  6. # 使用Zookeeper进行连接的无法查看
  7. ./bin/kafka-consumer-groups.sh --bootstrap-server 127.0.0.1:9092 --describe --group g_demo
  8. # 使用Zookeeper进行连接使用如下命令
  9. ./bin/kafka-consumer-groups.sh --zookeeper localhost:2181 --describe --group my-group
  10. # 拓展分片
  11. ./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic test --partitions 4
  12. # 查看topic信息
  13. ./bin/kafka-topics.sh --zookeeper localhost:2181 --list
  14. ./bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic ALS
  15. ./bin/kafka-verifiable-consumer.sh --broker-list localhost:9092 --topic ALS --group-id g_demo
  16. ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group g_demo --members
  17. ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group g_demo --members --verbose
  18. ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group g_demo --state
  19. bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --delete --group my-group --group my-other-group

./bin/kafka-run-class.sh kafka.admin.ConsumerGroupCommand —zookeeper localhost:2181 —list
./bin/kafka-run-class.sh kafka.admin.ConsumerGroupCommand —zookeeper localhost:2181 —describe —group group1

./bin/kafka-run-class.sh kafka.admin.ConsumerGroupCommand —bootstrap-server localhost:9092 —list
./bin/kafka-run-class.sh kafka.admin.ConsumerGroupCommand —bootstrap-server localhost:9092 —describe —group demo