Confluent Kafka REST代理对接器confluentinc/cp-kafka-rest:6.2.1 -由于LOG4J错误而无法启动

ahy6op9u  于 2022-11-06  发布在  Kafka
关注(0)|答案(1)|浏览(228)

我的配置:

kafka-rest-1:
    image: confluentinc/cp-kafka-rest:6.2.1
    hostname: kafka-rest-1
    container_name: kafka-rest-1
    depends_on:
      - zookeeper-1
      - broker-1
    ports:
      - "8082:8082"
    environment:
      KAFKA_REST_HOST_NAME: kafka-rest-1
      KAFKA_REST_LISTENERS: http://0.0.0.0:8082
      #KAFKA_REST_SCHEMA_REGISTRY_URL: 192.168.100.14:8081
      KAFKA_REST_ZOOKEEPER_CONNECT: 192.168.100.14:2181
      KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100:14:9092
    networks:
      - mynet

错误日志:

kafka-rest-1    | ===> User
kafka-rest-1    | uid=1000(appuser) gid=1000(appuser) groups=1000(appuser)
kafka-rest-1    | ===> Configuring ...
kafka-rest-1    | ===> Running preflight checks ...
kafka-rest-1    | ===> Check if Zookeeper is healthy ...
kafka-rest-1    | SLF4J: Class path contains multiple SLF4J bindings.
kafka-rest-1    | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
kafka-rest-1    | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
kafka-rest-1    | SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
kafka-rest-1    | SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
kafka-rest-1    | log4j:WARN No appenders could be found for logger (io.confluent.admin.utils.cli.ZookeeperReadyCommand).
kafka-rest-1    | log4j:WARN Please initialize the log4j system properly.
kafka-rest-1    | log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
kafka-rest-1    | ===> Check if Kafka is healthy ...
kafka-rest-1    | SLF4J: Class path contains multiple SLF4J bindings.
kafka-rest-1    | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
kafka-rest-1    | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
kafka-rest-1    | SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
kafka-rest-1    | SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
kafka-rest-1    | log4j:WARN No appenders could be found for logger (io.confluent.admin.utils.cli.KafkaReadyCommand).
kafka-rest-1    | log4j:WARN Please initialize the log4j system properly.
kafka-rest-1    | log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

我在这里读到了如何设置Kafka REST API:https://docs.confluent.io/platform/current/installation/docker/config-reference.html#crest-long-configuration
还找到了以下配置示例:https://github.com/conduktor/kafka-stack-docker-compose/blob/master/full-stack.yml
看来问题是:http://www.slf4j.org/codes.html#multiple_bindings如果我启用Schema Registry -它在日志中有同样的问题。
我可以如何解决上述问题,只是使用环境变量(s)在docker-compose.yml文件?这里描述的东西:https://docs.confluent.io/platform/current/installation/docker/operations/logging.html
已将我的配置更改为显示导出变量:

kafka-rest-1:
    image: confluentinc/cp-kafka-rest:6.2.1
    hostname: kafka-rest-1
    container_name: kafka-rest-1
    depends_on:
      - zookeeper-1
      - broker-1
    ports:
      - "8082:8082"
    environment:
      KAFKA_REST_HOST_NAME: 'kafka-rest-1'
      KAFKA_REST_LISTENERS: 'http://0.0.0.0:8082'
      KAFKA_REST_ZOOKEEPER_CONNECT: '192.168.100.14:2181'
      KAFKA_REST_BOOTSTRAP_SERVERS: '192.168.100:14:9092'
    command:
      - bash
      - -c
      - |
        export & kafka-rest-start
    networks:
      - mynet

完整的日志显示listers、zookeeper.connect和bootstrap.servers未设置:

root@lab:/home/pvadmin/Kafka-Docker# docker-compose up kafka-rest-1
zookeeper-1 is up-to-date
broker-1 is up-to-date
Recreating kafka-rest-1 ... done
Attaching to kafka-rest-1
kafka-rest-1    | declare -x COMPONENT="kafka-rest"
kafka-rest-1    | declare -x CUB_CLASSPATH="\"/usr/share/java/cp-base-new/*\""
kafka-rest-1    | declare -x HOME="/home/appuser"
kafka-rest-1    | declare -x HOSTNAME="kafka-rest-1"
kafka-rest-1    | declare -x KAFKA_REST_BOOTSTRAP_SERVERS="192.168.100:14:9092"
kafka-rest-1    | declare -x KAFKA_REST_HOST_NAME="kafka-rest-1"
kafka-rest-1    | declare -x KAFKA_REST_LISTENERS="http://0.0.0.0:8082"
kafka-rest-1    | declare -x KAFKA_REST_ZOOKEEPER_CONNECT="192.168.100.14:2181"
kafka-rest-1    | declare -x LANG="C.UTF-8"
kafka-rest-1    | declare -x OLDPWD
kafka-rest-1    | declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
kafka-rest-1    | declare -x PWD="/home/appuser"
kafka-rest-1    | declare -x SHLVL="1"
kafka-rest-1    | declare -x container="oci"
kafka-rest-1    | log4j:ERROR setFile(null,true) call failed.
kafka-rest-1    | java.io.FileNotFoundException: /kafka-rest.log (Permission denied)
kafka-rest-1    |       at java.base/java.io.FileOutputStream.open0(Native Method)
kafka-rest-1    |       at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
kafka-rest-1    |       at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
kafka-rest-1    |       at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:158)
kafka-rest-1    |       at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
kafka-rest-1    |       at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
kafka-rest-1    |       at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
kafka-rest-1    |       at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
kafka-rest-1    |       at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
kafka-rest-1    |       at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
kafka-rest-1    |       at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
kafka-rest-1    |       at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
kafka-rest-1    |       at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
kafka-rest-1    |       at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
kafka-rest-1    |       at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
kafka-rest-1    |       at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
kafka-rest-1    |       at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
kafka-rest-1    |       at org.slf4j.impl.Log4jLoggerFactory.<init>(Log4jLoggerFactory.java:66)
kafka-rest-1    |       at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72)
kafka-rest-1    |       at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
kafka-rest-1    |       at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
kafka-rest-1    |       at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
kafka-rest-1    |       at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
kafka-rest-1    |       at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
kafka-rest-1    |       at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
kafka-rest-1    |       at io.confluent.kafkarest.KafkaRestMain.<clinit>(KafkaRestMain.java:28)
kafka-rest-1    | [2021-10-25 13:15:36,226] INFO KafkaRestConfig values:
kafka-rest-1    |       access.control.allow.headers =
kafka-rest-1    |       access.control.allow.methods =
kafka-rest-1    |       access.control.allow.origin =
kafka-rest-1    |       access.control.skip.options = true
kafka-rest-1    |       advertised.listeners = []
kafka-rest-1    |       api.endpoints.blocklist = []
kafka-rest-1    |       api.v2.enable = true
kafka-rest-1    |       api.v3.enable = true
kafka-rest-1    |       authentication.method = NONE
kafka-rest-1    |       authentication.realm =
kafka-rest-1    |       authentication.roles = [*]
kafka-rest-1    |       authentication.skip.paths = []
kafka-rest-1    |       bootstrap.servers =
kafka-rest-1    |       client.init.timeout.ms = 60000
kafka-rest-1    |       client.sasl.kerberos.kinit.cmd = /usr/bin/kinit
kafka-rest-1    |       client.sasl.kerberos.min.time.before.relogin = 60000
kafka-rest-1    |       client.sasl.kerberos.service.name =
kafka-rest-1    |       client.sasl.kerberos.ticket.renew.jitter = 0.05
kafka-rest-1    |       client.sasl.kerberos.ticket.renew.window.factor = 0.8
kafka-rest-1    |       client.sasl.mechanism = GSSAPI
kafka-rest-1    |       client.security.protocol = PLAINTEXT
kafka-rest-1    |       client.ssl.cipher.suites =
kafka-rest-1    |       client.ssl.enabled.protocols = TLSv1.2,TLSv1.1,TLSv1
kafka-rest-1    |       client.ssl.endpoint.identification.algorithm =
kafka-rest-1    |       client.ssl.key.password = [hidden]
kafka-rest-1    |       client.ssl.keymanager.algorithm = SunX509
kafka-rest-1    |       client.ssl.keystore.location =
kafka-rest-1    |       client.ssl.keystore.password = [hidden]
kafka-rest-1    |       client.ssl.keystore.type = JKS
kafka-rest-1    |       client.ssl.protocol = TLS
kafka-rest-1    |       client.ssl.provider =
kafka-rest-1    |       client.ssl.trustmanager.algorithm = PKIX
kafka-rest-1    |       client.ssl.truststore.location =
kafka-rest-1    |       client.ssl.truststore.password = [hidden]
kafka-rest-1    |       client.ssl.truststore.type = JKS
kafka-rest-1    |       client.timeout.ms = 500
kafka-rest-1    |       client.zk.session.timeout.ms = 30000
kafka-rest-1    |       compression.enable = true
kafka-rest-1    |       confluent.resource.name.authority =
kafka-rest-1    |       consumer.instance.timeout.ms = 300000
kafka-rest-1    |       consumer.iterator.backoff.ms = 50
kafka-rest-1    |       consumer.iterator.timeout.ms = 1
kafka-rest-1    |       consumer.request.max.bytes = 67108864
kafka-rest-1    |       consumer.request.timeout.ms = 1000
kafka-rest-1    |       consumer.threads = 50
kafka-rest-1    |       csrf.prevention.enable = false
kafka-rest-1    |       csrf.prevention.token.endpoint = /csrf
kafka-rest-1    |       csrf.prevention.token.expiration.minutes = 30
kafka-rest-1    |       csrf.prevention.token.max.entries = 10000
kafka-rest-1    |       debug = false
kafka-rest-1    |       dos.filter.delay.ms = 100
kafka-rest-1    |       dos.filter.enabled = false
kafka-rest-1    |       dos.filter.insert.headers = true
kafka-rest-1    |       dos.filter.ip.whitelist = []
kafka-rest-1    |       dos.filter.managed.attr = false
kafka-rest-1    |       dos.filter.max.idle.tracker.ms = 30000
kafka-rest-1    |       dos.filter.max.requests.ms = 30000
kafka-rest-1    |       dos.filter.max.requests.per.sec = 25
kafka-rest-1    |       dos.filter.max.wait.ms = 50
kafka-rest-1    |       dos.filter.remote.port = false
kafka-rest-1    |       dos.filter.throttle.ms = 30000
kafka-rest-1    |       dos.filter.throttled.requests = 5
kafka-rest-1    |       dos.filter.track.sessions = true
kafka-rest-1    |       fetch.min.bytes = -1
kafka-rest-1    |       host.name =
kafka-rest-1    |       id =
kafka-rest-1    |       idle.timeout.ms = 30000
kafka-rest-1    |       kafka.rest.resource.extension.class = []
kafka-rest-1    |       listeners = []
kafka-rest-1    |       metric.reporters = []
kafka-rest-1    |       metrics.jmx.prefix = kafka.rest
kafka-rest-1    |       metrics.num.samples = 2
kafka-rest-1    |       metrics.sample.window.ms = 30000
kafka-rest-1    |       metrics.tag.map = []
kafka-rest-1    |       port = 8082
kafka-rest-1    |       producer.threads = 5
kafka-rest-1    |       request.logger.name = io.confluent.rest-utils.requests
kafka-rest-1    |       request.queue.capacity = 2147483647
kafka-rest-1    |       request.queue.capacity.growby = 64
kafka-rest-1    |       request.queue.capacity.init = 128
kafka-rest-1    |       resource.extension.classes = []
kafka-rest-1    |       response.http.headers.config =
kafka-rest-1    |       response.mediatype.default = application/json
kafka-rest-1    |       response.mediatype.preferred = [application/json, application/vnd.kafka.v2+json]
kafka-rest-1    |       rest.servlet.initializor.classes = []
kafka-rest-1    |       schema.registry.url = http://localhost:8081
kafka-rest-1    |       shutdown.graceful.ms = 1000
kafka-rest-1    |       simpleconsumer.pool.size.max = 25
kafka-rest-1    |       simpleconsumer.pool.timeout.ms = 1000
kafka-rest-1    |       ssl.cipher.suites = []
kafka-rest-1    |       ssl.client.auth = false
kafka-rest-1    |       ssl.client.authentication = NONE
kafka-rest-1    |       ssl.enabled.protocols = []
kafka-rest-1    |       ssl.endpoint.identification.algorithm = null
kafka-rest-1    |       ssl.key.password = [hidden]
kafka-rest-1    |       ssl.keymanager.algorithm =
kafka-rest-1    |       ssl.keystore.location =
kafka-rest-1    |       ssl.keystore.password = [hidden]
kafka-rest-1    |       ssl.keystore.reload = false
kafka-rest-1    |       ssl.keystore.type = JKS
kafka-rest-1    |       ssl.keystore.watch.location =
kafka-rest-1    |       ssl.protocol = TLS
kafka-rest-1    |       ssl.provider =
kafka-rest-1    |       ssl.trustmanager.algorithm =
kafka-rest-1    |       ssl.truststore.location =
kafka-rest-1    |       ssl.truststore.password = [hidden]
kafka-rest-1    |       ssl.truststore.type = JKS
kafka-rest-1    |       thread.pool.max = 200
kafka-rest-1    |       thread.pool.min = 8
kafka-rest-1    |       websocket.path.prefix = /ws
kafka-rest-1    |       websocket.servlet.initializor.classes = []
kafka-rest-1    |       zookeeper.connect =
kafka-rest-1    |  (io.confluent.kafkarest.KafkaRestConfig:372)
kafka-rest-1    | [2021-10-25 13:15:36,305] INFO Logging initialized @911ms to org.eclipse.jetty.util.log.Slf4jLog (org.eclipse.jetty.util.log:170)
kafka-rest-1    | [2021-10-25 13:15:36,316] INFO Initial capacity 128, increased by 64, maximum capacity 2147483647. (io.confluent.rest.ApplicationServer:490)
kafka-rest-1    | [2021-10-25 13:15:36,425] WARN DEPRECATION warning: `listeners` configuration is not configured. Falling back to the deprecated `port` configuration. (io.confluent.rest.ApplicationServer:107)
kafka-rest-1    | [2021-10-25 13:15:36,425] INFO Adding listener: http://0.0.0.0:8082 (io.confluent.rest.ApplicationServer:384)
kafka-rest-1    | [2021-10-25 13:15:36,760] ERROR Server died unexpectedly:  (io.confluent.kafkarest.KafkaRestMain:62)
kafka-rest-1    | java.lang.RuntimeException: Atleast one of bootstrap.servers or zookeeper.connect needs to be configured
kafka-rest-1    |       at io.confluent.kafkarest.KafkaRestApplication.setupResources(KafkaRestApplication.java:91)
kafka-rest-1    |       at io.confluent.kafkarest.KafkaRestApplication.setupResources(KafkaRestApplication.java:55)
kafka-rest-1    |       at io.confluent.rest.Application.configureHandler(Application.java:265)
kafka-rest-1    |       at io.confluent.rest.ApplicationServer.doStart(ApplicationServer.java:227)
kafka-rest-1    |       at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
kafka-rest-1    |       at io.confluent.rest.Application.start(Application.java:653)
kafka-rest-1    |       at io.confluent.kafkarest.KafkaRestMain.main(KafkaRestMain.java:55)
kafka-rest-1 exited with code 1

为什么docker-compose.yml环境变量不应用于config?
我能够以某种方式运行6.0.0版本:

kafka-rest-1:
    image: confluentinc/cp-kafka-rest:6.0.0
    hostname: kafka-rest-1
    container_name: kafka-rest-1
    depends_on:
      - zookeeper-1
      - broker-1
    ports:
      - "8082:8082"
    environment:
      KAFKA_REST_HOST_NAME: kafka-rest-1
      KAFKA_REST_LISTENERS: http://0.0.0.0:8082

# KAFKA_REST_SCHEMA_REGISTRY_URL: 192.168.100.14:8081

# KAFKA_REST_ZOOKEEPER_CONNECT: 192.168.100.14:2181

      KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092

# command:

# - bash

# - -c

# - |

# export & kafka-rest-start

    networks:
      - mynet
bxfogqkk

bxfogqkk1#

使用此配置可以正常工作:

kafka-rest-1:
    image: confluentinc/cp-kafka-rest:6.2.1
    hostname: kafka-rest-1
    container_name: kafka-rest-1
    depends_on:
      - zookeeper-1
      - broker-1
    ports:
      - "8082:8082"
    environment:
      KAFKA_REST_HOST_NAME: 192.168.100.14
      KAFKA_REST_LISTENERS: http://0.0.0.0:8082

# KAFKA_REST_SCHEMA_REGISTRY_URL: 192.168.100.14:8081

# KAFKA_REST_ZOOKEEPER_CONNECT: 192.168.100.14:2181

      KAFKA_REST_BOOTSTRAP_SERVERS: 192.168.100.14:9092
    networks:
      - mynet

问题也许是在“:“符号的错误位置:KAFKA_REST_引导程序_服务器:192.168.100:14:9092
此外,它仅在没有KAFKA_REST_ZOOKEEPER_CONNECT选项的情况下工作。

相关问题