`/opt/homebrew/Cellar/kafka/3.9.0/bin/zookeeper-server-start /opt/homebrew/etc/kafka/zookeeper.properties &`
这行命令用于在 Unix-like 操作系统上启动 ZooKeeper 服务器。`/opt/homebrew/Cellar/kafka/3.9.0/bin/zookeeper-server-start` 是 ZooKeeper 服务器启动脚本的路径,`/opt/homebrew/etc/kafka/zookeeper.properties` 是 ZooKeeper 配置文件的路径。`&` 符号表示在后台运行这个命令。
`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-server-start /opt/homebrew/etc/kafka/server.properties &`
这行命令用于在 Unix-like 操作系统上启动 Kafka 服务器。`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-server-start` 是 Kafka 服务器启动脚本的路径,`/opt/homebrew/etc/kafka/server.properties` 是 Kafka 配置文件的路径。`&` 符号表示在后台运行这个命令。
`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-topics --create --topic test-events --bootstrap-server localhost:9092`
这行命令用于创建一个名为 `test-events` 的 Kafka 主题。`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-topics` 是管理 Kafka 主题的脚本,`--create` 选项表示创建一个新主题,`--topic` 选项指定主题名称,`--bootstrap-server` 选项指定 Kafka 服务器的地址。
`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-topics --describe --topic test-events --bootstrap-server localhost:9092`
这行命令用于查看名为 `test-events` 的 Kafka 主题的详细信息。`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-topics` 是管理 Kafka 主题的脚本,`--describe` 选项表示查看主题的详细信息,`--topic` 选项指定主题名称,`--bootstrap-server` 选项指定 Kafka 服务器的地址。
`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-console-producer --topic test-events --bootstrap-server localhost:9092`
这行命令用于在 Kafka 主题 `test-events` 中发布消息。`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-console-producer` 是一个命令行工具,允许用户在控制台中直接向 Kafka 主题发布消息。`--topic` 选项指定要发布消息的主题,`--bootstrap-server` 选项指定 Kafka 服务器的地址。
`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-console-consumer --topic test-events --from-beginning --bootstrap-server localhost:9092`
这行命令用于从 Kafka 主题 `test-events` 中消费消息。`/opt/homebrew/Cellar/kafka/3.9.0/bin/kafka-console-consumer` 是一个命令行工具,允许用户在控制台中直接从 Kafka 主题消费消息。`--topic` 选项指定要消费消息的主题,`--from-beginning` 选项表示从主题的开头开始消费消息,`--bootstrap-server` 选项指定 Kafka 服务器的地址。
参考: