kafak最新安装教程【kafka_2.13-3.9.0】双语版
Step 1: Get Kafka 第 1 步:获取 Kafka
Download the latest Kafka release and extract it:
下载最新的 Kafka 版本并提取它:
$ tar -xzf kafka_2.13-3.9.0.tgz
$ cd kafka_2.13-3.9.0
Step 2: Start the Kafka environment
第 2 步:启动 Kafka 环境
NOTE: Your local environment must have Java 8+ installed.
注意:您的本地环境必须安装 Java 8+。
Apache Kafka can be started using KRaft or ZooKeeper. To get started with either configuration follow one of the sections below but not both.
Apache Kafka 可以使用 KRaft 或 ZooKeeper 启动。要开始使用任一配置,请遵循以下部分之一,但不能同时执行这两部分。
Kafka with KRaft 带有 KRaft 的 Kafka
Kafka can be run using KRaft mode using local scripts and downloaded files or the docker image. Follow one of the sections below but not both to start the kafka server.
Kafka 可以使用本地脚本和下载的文件或 docker 镜像通过 KRaft 模式运行。按照以下部分之一(但不能同时执行)作启动 Kafka 服务器。
Using downloaded files 使用下载的文件
Generate a Cluster UUID 生成集群 UUID
$ KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
Format Log Directories 设置日志目录的格式
$ bin/kafka-storage.sh format --standalone -t $KAFKA_CLUSTER_ID -c config/kraft/reconfig-server.properties
Start the Kafka Server 启动 Kafka 服务器
$ bin/kafka-server-start.sh config/kraft/reconfig-server.properties
Once the Kafka server has successfully launched, you will have a basic Kafka environment running and ready to use.
成功启动 Kafka 服务器后,您将有一个基本的 Kafka 环境运行并可供使用。
Using JVM Based Apache Kafka Docker Image
使用基于 JVM 的 Apache Kafka Docker 镜像
Get the Docker image: 获取 Docker 镜像:
$ docker pull apache/kafka:3.9.0
Start the Kafka Docker container:
启动 Kafka Docker 容器:
$ docker run -p 9092:9092 apache/kafka:3.9.0
Using GraalVM Based Native Apache Kafka Docker Image
使用基于 GraalVM 的原生 Apache Kafka Docker 镜像
Get the Docker image: 获取 Docker 镜像:
$ docker pull apache/kafka-native:3.9.0
Start the Kafka Docker container:
启动 Kafka Docker 容器:
$ docker run -p 9092:9092 apache/kafka-native:3.9.0
Kafka with ZooKeeper 带有 ZooKeeper 的 Kafka
Run the following commands in order to start all services in the correct order:
运行以下命令以按正确顺序启动所有服务:
Start the ZooKeeper service
$ bin/zookeeper-server-start.sh config/zookeeper.properties
Open another terminal session and run:
打开另一个终端会话并运行:
Start the Kafka broker service
$ bin/kafka-server-start.sh co