v3.1.x将彻底移除kafka
Kafka无Zookeeper启动
#!/bin/bash
#注意3.0属于测试版
basePath=/www/kafka_2.13-3.0.0
kraftPath=/tmp/kraft-combined-logs
if [[ ! -d "$kraftPath" ]]; then
echo "Kafka 初始化Kraft"
uuid=$($basePath/bin/kafka-storage.sh random-uuid)
echo "$uuid"
$basePath/bin/kafka-storage.sh format -t $uuid -c $basePath/config/kraft/server.properties
else
echo "Kafka 已使用Kraft"
fi
$basePath/bin/kafka-server-start.sh -daemon $basePath/config/kraft/server.properties
本地方式
bin/zookeeper-server-start.sh config/zookeeper.properties
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
## 查看全部消费组
./bin/kafka-consumer-groups.sh --list --bootstrap-server 127.0.0.1:9092
# 使用Zookeeper进行连接使用如下命令
./bin/kafka-consumer-groups.sh --list --zookeeper localhost:2181
## 查看消费组详情
# 使用Zookeeper进行连接的无法查看
./bin/kafka-consumer-groups.sh --bootstrap-server 127.0.0.1:9092 --describe --group g_demo
# 使用Zookeeper进行连接使用如下命令
./bin/kafka-consumer-groups.sh --zookeeper localhost:2181 --describe --group my-group
# 拓展分片
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic test --partitions 4
# 查看topic信息
./bin/kafka-topics.sh --zookeeper localhost:2181 --list
./bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic ALS
./bin/kafka-verifiable-consumer.sh --broker-list localhost:9092 --topic ALS --group-id g_demo
./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group g_demo --members
./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group g_demo --members --verbose
./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group g_demo --state
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