Trying to start kafka , Schema registry in docker containers using Testcontainers

huangapple go评论122阅读模式
英文:

Trying to start kafka , Schema registry in docker containers using Testcontainers

问题

我正在尝试在 Docker 容器中使用 Kotlin 进行集成测试和 Test containers 启动 Kafka 和 schemaregistry。以下是我的 Test containers 设置:

  1. @Testcontainers
  2. companion object {
  3. @Container
  4. val kafkaContainer = KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest")).apply {
  5. setWaitStrategy(
  6. Wait.defaultWaitStrategy()
  7. .withStartupTimeout(Duration.ofSeconds(75))
  8. )
  9. withEmbeddedZookeeper()
  10. .withEnv("KAFKA_LISTENERS", "PLAINTEXT://0.0.0.0:9093 ,BROKER://0.0.0.0:9092")
  11. .withEnv("KAFKA_LISTENER_SECURITY_PROTOCOL_MAP", "BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXT")
  12. .withEnv("KAFKA_INTER_BROKER_LISTENER_NAME", "BROKER")
  13. .withEnv("KAFKA_BROKER_ID", "1")
  14. .withEnv("KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "1")
  15. .withEnv("KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS", "1")
  16. .withEnv("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "1")
  17. .withEnv("KAFKA_TRANSACTION_STATE_LOG_MIN_ISR", "1")
  18. .withEnv("KAFKA_LOG_FLUSH_INTERVAL_MESSAGES", Long.MAX_VALUE.toString())
  19. .withEnv("KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS", "0")
  20. .start()
  21. }.withReuse(true)
  22. @Container
  23. val schemaRegistryContainer = GenericContainer(DockerImageName.parse("confluentinc/cp-schema-registry")).apply {
  24. withExposedPorts(8081)
  25. withEnv("SCHEMA_REGISTRY_HOST_NAME", "schema-registry")
  26. withEnv("SCHEMA_REGISTRY_LISTENERS", "http://localhost:8081")
  27. withEnv("SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", kafkaContainer.bootstrapServers)
  28. withNetwork(kafkaContainer.network)
  29. start()
  30. }
  31. @DynamicPropertySource
  32. @JvmStatic
  33. fun kafkaProperties(registry: DynamicPropertyRegistry) {
  34. registry.add("kafka.bootstrapServers") { kafkaContainer.bootstrapServers }
  35. registry.add("kafka.schemaRegistryUrl") { "localhost:${schemaRegistryContainer.exposedPorts}" }
  36. }
  37. }

我可以看到我的 Kafka 代理正在运行,但是当启动 schema-registry 时,我在 Docker 日志中看到以下错误:

  1. 2023-04-06 13:41:04 ==> User
  2. 2023-04-06 13:41:04 uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
  3. 2023-04-06 13:41:04 ==> Configuring ...
  4. ...
  5. (以下省略了一些日志)
  6. ...
  7. 2023-04-06 13:41:36 org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: fetchMetadata
  8. 2023-04-06 13:41:36 [2023-04-06 11:41:36,929] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected.
  9. 2023-04-06 13:41:36 [2023-04-06 11:41:36,929] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available.
  10. ...

希望这能帮助您解决问题。

英文:

I am trying to start kafka and schemaregistry in docker containers using my integration tests and Test containers in Kotlin.

Here is my Test containers setup :

  1. @Testcontainers
  2. companion object {
  3. @Container
  4. val kafkaContainer = KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:latest")).apply {
  5. setWaitStrategy(
  6. Wait.defaultWaitStrategy()
  7. .withStartupTimeout(Duration.ofSeconds(75))
  8. )
  9. withEmbeddedZookeeper()
  10. .withEnv("KAFKA_LISTENERS", "PLAINTEXT://0.0.0.0:9093 ,BROKER://0.0.0.0:9092")
  11. .withEnv("KAFKA_LISTENER_SECURITY_PROTOCOL_MAP", "BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXT")
  12. .withEnv("KAFKA_INTER_BROKER_LISTENER_NAME", "BROKER")
  13. .withEnv("KAFKA_BROKER_ID", "1")
  14. .withEnv("KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "1")
  15. .withEnv("KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS", "1")
  16. .withEnv("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "1")
  17. .withEnv("KAFKA_TRANSACTION_STATE_LOG_MIN_ISR", "1")
  18. .withEnv("KAFKA_LOG_FLUSH_INTERVAL_MESSAGES", Long.MAX_VALUE.toString())
  19. .withEnv("KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS", "0")
  20. .start()
  21. }.withReuse(true)
  22. @Container
  23. val schemaRegistryContainer = GenericContainer(DockerImageName.parse("confluentinc/cp-schema-registry")).apply {
  24. withExposedPorts(8081)
  25. withEnv("SCHEMA_REGISTRY_HOST_NAME", "schema-registry")
  26. withEnv("SCHEMA_REGISTRY_LISTENERS", "http://localhost:8081")
  27. withEnv("SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", kafkaContainer.bootstrapServers)
  28. withNetwork(kafkaContainer.network)
  29. start()
  30. }
  31. @DynamicPropertySource
  32. @JvmStatic
  33. fun kafkaProperties(registry: DynamicPropertyRegistry) {
  34. registry.add("kafka.bootstrapServers") { kafkaContainer.bootstrapServers }
  35. registry.add("kafka.schemaRegistryUrl") { "localhost:${schemaRegistryContainer.exposedPorts}" }
  36. }

i can see that my kafka broker is up and running :
enter image description here

So kafka starts first then when schema-registry is starting i see this error in docker logs :

  1. 2023-04-06 13:41:04 ===> User
  2. 2023-04-06 13:41:04 uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
  3. 2023-04-06 13:41:04 ===> Configuring ...
  4. 2023-04-06 13:41:05 ===> Running preflight checks ...
  5. 2023-04-06 13:41:05 ===> Check if Kafka is healthy ...
  6. 2023-04-06 13:41:06 [2023-04-06 11:41:06,161] INFO AdminClientConfig values:
  7. 2023-04-06 13:41:06 bootstrap.servers = [PLAINTEXT://localhost:60422]
  8. 2023-04-06 13:41:06 client.dns.lookup = use_all_dns_ips
  9. 2023-04-06 13:41:06 client.id =
  10. 2023-04-06 13:41:06 connections.max.idle.ms = 300000
  11. 2023-04-06 13:41:06 default.api.timeout.ms = 60000
  12. 2023-04-06 13:41:06 metadata.max.age.ms = 300000
  13. 2023-04-06 13:41:06 metric.reporters = []
  14. 2023-04-06 13:41:06 metrics.num.samples = 2
  15. 2023-04-06 13:41:06 metrics.recording.level = INFO
  16. 2023-04-06 13:41:06 metrics.sample.window.ms = 30000
  17. 2023-04-06 13:41:06 receive.buffer.bytes = 65536
  18. 2023-04-06 13:41:06 reconnect.backoff.max.ms = 1000
  19. 2023-04-06 13:41:06 reconnect.backoff.ms = 50
  20. 2023-04-06 13:41:06 request.timeout.ms = 30000
  21. 2023-04-06 13:41:06 retries = 2147483647
  22. 2023-04-06 13:41:06 retry.backoff.ms = 100
  23. 2023-04-06 13:41:06 sasl.client.callback.handler.class = null
  24. 2023-04-06 13:41:06 sasl.jaas.config = null
  25. 2023-04-06 13:41:06 sasl.kerberos.kinit.cmd = /usr/bin/kinit
  26. 2023-04-06 13:41:06 sasl.kerberos.min.time.before.relogin = 60000
  27. 2023-04-06 13:41:06 sasl.kerberos.service.name = null
  28. 2023-04-06 13:41:06 sasl.kerberos.ticket.renew.jitter = 0.05
  29. 2023-04-06 13:41:06 sasl.kerberos.ticket.renew.window.factor = 0.8
  30. 2023-04-06 13:41:06 sasl.login.callback.handler.class = null
  31. 2023-04-06 13:41:06 sasl.login.class = null
  32. 2023-04-06 13:41:06 sasl.login.connect.timeout.ms = null
  33. 2023-04-06 13:41:06 sasl.login.read.timeout.ms = null
  34. 2023-04-06 13:41:06 sasl.login.refresh.buffer.seconds = 300
  35. 2023-04-06 13:41:06 sasl.login.refresh.min.period.seconds = 60
  36. 2023-04-06 13:41:06 sasl.login.refresh.window.factor = 0.8
  37. 2023-04-06 13:41:06 sasl.login.refresh.window.jitter = 0.05
  38. 2023-04-06 13:41:06 sasl.login.retry.backoff.max.ms = 10000
  39. 2023-04-06 13:41:06 sasl.login.retry.backoff.ms = 100
  40. 2023-04-06 13:41:06 sasl.mechanism = GSSAPI
  41. 2023-04-06 13:41:06 sasl.oauthbearer.clock.skew.seconds = 30
  42. 2023-04-06 13:41:06 sasl.oauthbearer.expected.audience = null
  43. 2023-04-06 13:41:06 sasl.oauthbearer.expected.issuer = null
  44. 2023-04-06 13:41:06 sasl.oauthbearer.jwks.endpoint.refresh.ms = 3600000
  45. 2023-04-06 13:41:06 sasl.oauthbearer.jwks.endpoint.retry.backoff.max.ms = 10000
  46. 2023-04-06 13:41:06 sasl.oauthbearer.jwks.endpoint.retry.backoff.ms = 100
  47. 2023-04-06 13:41:06 sasl.oauthbearer.jwks.endpoint.url = null
  48. 2023-04-06 13:41:06 sasl.oauthbearer.scope.claim.name = scope
  49. 2023-04-06 13:41:06 sasl.oauthbearer.sub.claim.name = sub
  50. 2023-04-06 13:41:06 sasl.oauthbearer.token.endpoint.url = null
  51. 2023-04-06 13:41:06 security.protocol = PLAINTEXT
  52. 2023-04-06 13:41:06 security.providers = null
  53. 2023-04-06 13:41:06 send.buffer.bytes = 131072
  54. 2023-04-06 13:41:06 socket.connection.setup.timeout.max.ms = 30000
  55. 2023-04-06 13:41:06 socket.connection.setup.timeout.ms = 10000
  56. 2023-04-06 13:41:06 ssl.cipher.suites = null
  57. 2023-04-06 13:41:06 ssl.enabled.protocols = [TLSv1.2, TLSv1.3]
  58. 2023-04-06 13:41:06 ssl.endpoint.identification.algorithm = https
  59. 2023-04-06 13:41:06 ssl.engine.factory.class = null
  60. 2023-04-06 13:41:06 ssl.key.password = null
  61. 2023-04-06 13:41:06 ssl.keymanager.algorithm = SunX509
  62. 2023-04-06 13:41:06 ssl.keystore.certificate.chain = null
  63. 2023-04-06 13:41:06 ssl.keystore.key = null
  64. 2023-04-06 13:41:06 ssl.keystore.location = null
  65. 2023-04-06 13:41:06 ssl.keystore.password = null
  66. 2023-04-06 13:41:06 ssl.keystore.type = JKS
  67. 2023-04-06 13:41:06 ssl.protocol = TLSv1.3
  68. 2023-04-06 13:41:06 ssl.provider = null
  69. 2023-04-06 13:41:06 ssl.secure.random.implementation = null
  70. 2023-04-06 13:41:06 ssl.trustmanager.algorithm = PKIX
  71. 2023-04-06 13:41:06 ssl.truststore.certificates = null
  72. 2023-04-06 13:41:06 ssl.truststore.location = null
  73. 2023-04-06 13:41:06 ssl.truststore.password = null
  74. 2023-04-06 13:41:06 ssl.truststore.type = JKS
  75. 2023-04-06 13:41:06 (org.apache.kafka.clients.admin.AdminClientConfig)
  76. 2023-04-06 13:41:06 [2023-04-06 11:41:06,308] INFO Kafka version: 7.3.3-ccs (org.apache.kafka.common.utils.AppInfoParser)
  77. 2023-04-06 13:41:06 [2023-04-06 11:41:06,309] INFO Kafka commitId: 37ce202868a57983 (org.apache.kafka.common.utils.AppInfoParser)
  78. 2023-04-06 13:41:06 [2023-04-06 11:41:06,309] INFO Kafka startTimeMs: 1680781266306 (org.apache.kafka.common.utils.AppInfoParser)
  79. 2023-04-06 13:41:06 [2023-04-06 11:41:06,332] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  80. 2023-04-06 13:41:06 [2023-04-06 11:41:06,335] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  81. 2023-04-06 13:41:06 [2023-04-06 11:41:06,439] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  82. 2023-04-06 13:41:06 [2023-04-06 11:41:06,439] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  83. 2023-04-06 13:41:06 [2023-04-06 11:41:06,540] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  84. 2023-04-06 13:41:06 [2023-04-06 11:41:06,540] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  85. 2023-04-06 13:41:06 [2023-04-06 11:41:06,844] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  86. 2023-04-06 13:41:06 [2023-04-06 11:41:06,844] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  87. 2023-04-06 13:41:07 [2023-04-06 11:41:07,249] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  88. 2023-04-06 13:41:07 [2023-04-06 11:41:07,249] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  89. 2023-04-06 13:41:08 [2023-04-06 11:41:08,188] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  90. 2023-04-06 13:41:08 [2023-04-06 11:41:08,189] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  91. 2023-04-06 13:41:09 [2023-04-06 11:41:09,106] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  92. 2023-04-06 13:41:09 [2023-04-06 11:41:09,106] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  93. 2023-04-06 13:41:10 [2023-04-06 11:41:10,218] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  94. 2023-04-06 13:41:10 [2023-04-06 11:41:10,218] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  95. 2023-04-06 13:41:11 [2023-04-06 11:41:11,134] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  96. 2023-04-06 13:41:11 [2023-04-06 11:41:11,135] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  97. 2023-04-06 13:41:12 [2023-04-06 11:41:12,158] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  98. 2023-04-06 13:41:12 [2023-04-06 11:41:12,158] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  99. 2023-04-06 13:41:13 [2023-04-06 11:41:13,066] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  100. 2023-04-06 13:41:13 [2023-04-06 11:41:13,066] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  101. 2023-04-06 13:41:14 [2023-04-06 11:41:14,083] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  102. 2023-04-06 13:41:14 [2023-04-06 11:41:14,083] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  103. 2023-04-06 13:41:14 [2023-04-06 11:41:14,999] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  104. 2023-04-06 13:41:14 [2023-04-06 11:41:14,999] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  105. 2023-04-06 13:41:16 [2023-04-06 11:41:16,121] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  106. 2023-04-06 13:41:16 [2023-04-06 11:41:16,121] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  107. 2023-04-06 13:41:17 [2023-04-06 11:41:17,041] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  108. 2023-04-06 13:41:17 [2023-04-06 11:41:17,041] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  109. 2023-04-06 13:41:17 [2023-04-06 11:41:17,957] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  110. 2023-04-06 13:41:17 [2023-04-06 11:41:17,957] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  111. 2023-04-06 13:41:18 [2023-04-06 11:41:18,871] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  112. 2023-04-06 13:41:18 [2023-04-06 11:41:18,871] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  113. 2023-04-06 13:41:20 [2023-04-06 11:41:20,089] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  114. 2023-04-06 13:41:20 [2023-04-06 11:41:20,089] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  115. 2023-04-06 13:41:21 [2023-04-06 11:41:21,305] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  116. 2023-04-06 13:41:21 [2023-04-06 11:41:21,305] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  117. 2023-04-06 13:41:22 [2023-04-06 11:41:22,319] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  118. 2023-04-06 13:41:22 [2023-04-06 11:41:22,319] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  119. 2023-04-06 13:41:23 [2023-04-06 11:41:23,339] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  120. 2023-04-06 13:41:23 [2023-04-06 11:41:23,339] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  121. 2023-04-06 13:41:24 [2023-04-06 11:41:24,251] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  122. 2023-04-06 13:41:24 [2023-04-06 11:41:24,251] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  123. 2023-04-06 13:41:25 [2023-04-06 11:41:25,268] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  124. 2023-04-06 13:41:25 [2023-04-06 11:41:25,268] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  125. 2023-04-06 13:41:26 [2023-04-06 11:41:26,483] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  126. 2023-04-06 13:41:26 [2023-04-06 11:41:26,483] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  127. 2023-04-06 13:41:27 [2023-04-06 11:41:27,497] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  128. 2023-04-06 13:41:27 [2023-04-06 11:41:27,497] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  129. 2023-04-06 13:41:28 [2023-04-06 11:41:28,620] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  130. 2023-04-06 13:41:28 [2023-04-06 11:41:28,620] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  131. 2023-04-06 13:41:29 [2023-04-06 11:41:29,628] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  132. 2023-04-06 13:41:29 [2023-04-06 11:41:29,628] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  133. 2023-04-06 13:41:30 [2023-04-06 11:41:30,746] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  134. 2023-04-06 13:41:30 [2023-04-06 11:41:30,746] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  135. 2023-04-06 13:41:31 [2023-04-06 11:41:31,959] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  136. 2023-04-06 13:41:31 [2023-04-06 11:41:31,959] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  137. 2023-04-06 13:41:32 [2023-04-06 11:41:32,992] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  138. 2023-04-06 13:41:32 [2023-04-06 11:41:32,992] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  139. 2023-04-06 13:41:34 [2023-04-06 11:41:34,212] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  140. 2023-04-06 13:41:34 [2023-04-06 11:41:34,212] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  141. 2023-04-06 13:41:35 [2023-04-06 11:41:35,128] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  142. 2023-04-06 13:41:35 [2023-04-06 11:41:35,128] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  143. 2023-04-06 13:41:36 [2023-04-06 11:41:36,049] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  144. 2023-04-06 13:41:36 [2023-04-06 11:41:36,049] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  145. 2023-04-06 13:41:36 [2023-04-06 11:41:36,317] INFO [AdminClient clientId=adminclient-1] Metadata update failed (org.apache.kafka.clients.admin.internals.AdminMetadataManager)
  146. 2023-04-06 13:41:36 org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: fetchMetadata
  147. 2023-04-06 13:41:36 [2023-04-06 11:41:36,929] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  148. 2023-04-06 13:41:36 [2023-04-06 11:41:36,929] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  149. 2023-04-06 13:41:37 [2023-04-06 11:41:37,844] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  150. 2023-04-06 13:41:37 [2023-04-06 11:41:37,844] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  151. 2023-04-06 13:41:38 [2023-04-06 11:41:38,965] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  152. 2023-04-06 13:41:38 [2023-04-06 11:41:38,965] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  153. 2023-04-06 13:41:39 [2023-04-06 11:41:39,880] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  154. 2023-04-06 13:41:39 [2023-04-06 11:41:39,880] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  155. 2023-04-06 13:41:40 [2023-04-06 11:41:40,800] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  156. 2023-04-06 13:41:40 [2023-04-06 11:41:40,800] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  157. 2023-04-06 13:41:41 [2023-04-06 11:41:41,914] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  158. 2023-04-06 13:41:41 [2023-04-06 11:41:41,914] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  159. 2023-04-06 13:41:43 [2023-04-06 11:41:43,134] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  160. 2023-04-06 13:41:43 [2023-04-06 11:41:43,134] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  161. 2023-04-06 13:41:44 [2023-04-06 11:41:44,258] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  162. 2023-04-06 13:41:44 [2023-04-06 11:41:44,259] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  163. 2023-04-06 13:41:45 [2023-04-06 11:41:45,273] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  164. 2023-04-06 13:41:45 [2023-04-06 11:41:45,273] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  165. 2023-04-06 13:41:46 [2023-04-06 11:41:46,318] ERROR Error while getting broker list. (io.confluent.admin.utils.ClusterStatus)
  166. 2023-04-06 13:41:46 java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: listNodes
  167. 2023-04-06 13:41:46 at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
  168. 2023-04-06 13:41:46 at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1999)
  169. 2023-04-06 13:41:46 at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:165)
  170. 2023-04-06 13:41:46 at io.confluent.admin.utils.ClusterStatus.isKafkaReady(ClusterStatus.java:147)
  171. 2023-04-06 13:41:46 at io.confluent.admin.utils.cli.KafkaReadyCommand.main(KafkaReadyCommand.java:149)
  172. 2023-04-06 13:41:46 Caused by: org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: listNodes
  173. 2023-04-06 13:41:46 [2023-04-06 11:41:46,422] INFO [AdminClient clientId=adminclient-1] Node -1 disconnected. (org.apache.kafka.clients.NetworkClient)
  174. 2023-04-06 13:41:46 [2023-04-06 11:41:46,422] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:60422) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
  175. 2023-04-06 13:41:47 [2023-04-06 11:41:47,323] INFO Expected 1 brokers but found only 0. Trying to query Kafka for metadata again ... (io.confluent.admin.utils.ClusterStatus)
  176. 2023-04-06 13:41:47 [2023-04-06 11:41:47,323] ERROR Expected 1 brokers but found only 0. Brokers found []. (io.confluent.admin.utils.ClusterStatus)
  177. 2023-04-06 13:41:47 Using log4j config /etc/schema-registry/log4j.properties

And the schema-registry container stops after this.
Any help would be much appreciated.

I expect this to start the schema -registry so that I can finally run tests

答案1

得分: 0

我通过将以下部分更改来解决这个错误:

withEnv("SCHEMA_REGISTRY_LISTENERS", "http://localhost:8081")

改为

withEnv("SCHEMA_REGISTRY_LISTENERS", "http://0.0.0.0:8081")

还有

registry.add("kafka.properties.schemaRegistryUrl") { "localhost:${schemaRegistryContainer.firstMappedPort}" }

改为

registry.add("kafka.properties.schemaRegistryUrl") { "http://${schemaRegistryContainer.host}:${schemaRegistryContainer.firstMappedPort}" }

希望对某人有所帮助 Trying to start kafka , Schema registry in docker containers using Testcontainers

英文:

I solved this error by changing

withEnv("SCHEMA_REGISTRY_LISTENERS", "http://localhost:8081")

to

withEnv("SCHEMA_REGISTRY_LISTENERS", "http://0.0.0.0:8081")

Also

registry.add("kafka.properties.schemaRegistryUrl") { "localhost:${schemaRegistryContainer.firstMappedPort}" }

to

registry.add("kafka.properties.schemaRegistryUrl") { "http://${schemaRegistryContainer.host}:${schemaRegistryContainer.firstMappedPort}" }

Hope this helps someone Trying to start kafka , Schema registry in docker containers using Testcontainers

huangapple
  • 本文由 发表于 2023年4月6日 19:50:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949187.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定