简体   繁体   English

使用属性文件配置kafka主题

[英]kafka topic configuration using properties file

I want to configure Kafka with some topics and their unique retention settings.我想使用一些主题及其独特的保留设置来配置 Kafka。 so when I start Kafka it will load the server.properties file with those settings.所以当我启动 Kafka 时,它将使用这些设置加载 server.properties 文件。

The only way I found was by starting Kafka, and then start and configure topics using kafka-topics.sh script.我发现的唯一方法是启动 Kafka,然后使用kafka-topics.sh脚本启动和配置主题。

Example:例子:

bin/kafka-topics.sh --zookeeper zk.yoursite.com --alter --topic as-access --config retention.ms=86400000

I am using Kafka over docker, so instead of setting the entry point to be the actual script that start Kafka, I need to create my own script which will start Kafka and run some shell commands to configure those topics.我在 docker 上使用 Kafka,所以我需要创建自己的脚本来启动 Kafka 并运行一些 shell 命令来配置这些主题,而不是将入口点设置为启动 Kafka 的实际脚本。 Also if I need to create those topics on my own, I need to start and create some logic regarding topics which already exist.此外,如果我需要自己创建这些主题,我需要开始并创建一些关于已经存在的主题的逻辑。 and I prefer not to go that road.而且我宁愿不要go那条路。

need to create my own script which will start Kafka and run some shell commands to configure those topics需要创建我自己的脚本来启动 Kafka 并运行一些 shell 命令来配置这些主题

  1. wurstmeister/kafka already supports KAFKA_CREATE_TOPICS environment variable for this purpose为此, wurstmeister/kafka已经支持KAFKA_CREATE_TOPICS环境变量

  2. It is recommended you use a second "init container", (or shell script around docker run/compose ) that waits for the other kafka container to start and be healthy, then do topic-creation.建议您使用第二个“init container”(或 shell 脚本docker run/compose )等待另一个 kafka 容器启动并保持健康,然后创建主题。 Related answer相关回答

  3. Just use AdminClient API in your client code to create topics before running producers or consumers.只需在客户端代码中使用 AdminClient API 即可在运行生产者或消费者之前创建主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kafka 无法使用 docker 创建主题 - Kafka cannot create topic using docker 使用docker将kafka主题数据写入redis - Write kafka topic data to redis using docker 无法使用 docker-compose 创建 kafka 主题 - Not able to create kafka topic using docker-compose 由于侦听器配置问题,无法连接到kafka。 得到错误`60000之后元数据中不存在主题测试” - Failing to connect to kafka due to listener configuration issue. Getting error `Topic testing not present in metadata after 60000` Debezium Postgres Kafka 没有创建主题 - Debezium Postgres Kafka not creating topic 在 Docker Compose 文件中设置 Kafka 消费者级别配置 - Setting Kafka Consumer Level Configuration in Docker Compose File 在 Docker 中创建 Kafka 主题从命令行工作,而不是从 Shell 脚本文件 - Create Kafka topic in Docker works from command line but not from Shell script file 如何使用 docker 命令将主题添加到正在运行的 kafka 容器? - how do i add a topic to a running kafka container using docker commands? 使用 python 从连接到另一个容器的容器创建一个新的 kafka 主题 - Create a new kafka topic using python from a container connecting to another container 卡夫卡制作人说“unknown_topic_or_partition” - Kafka producer says "unknown_topic_or_partition"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM