12

我有 windows 环境和我自己的一套 kafka 和 zookeeper 正在运行。为了使用自定义对象,我开始使用 Avro。但我需要启动注册表。下载 Confluent 平台并运行:

$ ./bin/schema-registry-start ./etc/schema-registry/schema-registry.properties
/c/Confluent/confluent-3.0.0-2.11/confluent-3.0.0/bin/schema-registry-run-class: line 103: C:\Program: No such file or directory

然后我在安装页面上看到了这个:

“Confluent 目前不支持 Windows。Windows 用户可以下载和使用 zip 和 tar 存档,但必须直接运行 jar 文件,而不是使用 bin/ 目录中的包装脚本。”

我想知道如何在 Windows 环境中启动融合模式注册表?

看了脚本的内容,很难破译。

谢谢

4

6 回答 6

10

有人按照 Ewen Cheslack-Postava 的建议创建了 Windows .bat 文件

https://github.com/renukaradhya/confluentplatform/tree/master/bin/windows

我保存schema-registry-run-class.batschema-registry-start.bat进入我的\confluent\bin\windows目录,然后能够运行架构注册表

C:\confluent\bin\windows\schema-registry-start.bat C:\confluent\etc\ schema-registry\schema-registry.properties

于 2018-05-28T17:31:29.703 回答
3

At the moment Confluent Platform does not ship with any scripts for Windows. However, you can write your own if you're comfortable with running Java applications. The schema-registry-server-start script (and the schema-registry-run-class script it depends on) do things like handle -daemon mode, set Java memory options, setup default log configuration, and more, but ultimately the key piece is that they execute Java with io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain as the main method. You might also find the kafka-run-class.bat from Kafka as a useful base: https://github.com/apache/kafka/blob/trunk/bin/windows/kafka-run-class.bat

于 2016-08-24T22:07:50.473 回答
2

问题可能是您的 Windows 环境的 JAVA_HOME 环境设置中存在空格(由 "C:\Program" 而不是 "C:\Program Files..." 的错误消息证明。

您可以通过添加将 schema-registry-run-class 脚本中的最后一个“exec”替换为单词“echo”来确定启动 schema_registry 的最终 java 调用的确切语法。你会看到相当复杂的命令

/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java -Xmx512M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlog4j.configuration=file:/opt/confluent/bin/../etc/schema-registry/log4j.properties -cp :/opt/confluent/bin/../package-schema-registry/target/kafka-schema-registry-package-*-development/share/java/schema-registry/*:/opt/confluent/bin/../share/java/confluent-common/*:/opt/confluent/bin/../share/java/rest-utils/*:/opt/confluent/bin/../share/java/schema-registry/* io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain

该命令归结为“java [core-java-opts] [java-defines] -cp [classpath] io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain

如果你用你的 Confluent 安装的实际位置替换“/opt/confluent”引用,我怀疑你会有更好的运气。

注意:我更喜欢在 Windows 上将 Java 安装到客户位置(例如“C:\java8”,因为许多标准脚本会在 C:\Program Files 部署位置出现问题。

于 2016-08-24T22:16:12.813 回答
1

架构注册表运行类 bat 文件的代码为:另存为 schema-registry-run-class.bat

@echo off

setlocal EnableExtensions EnableDelayedExpansion
pushd %~dp0..\..
set BASE_DIR=%CD%
popd

for %%i in (%BASE_DIR%/package-schema-registry/target/kafka-schema-registry-package-*-development) do (
    call :concat %%i/share/java/schema-registry/*
)

for %%i in (confluent-common, rest-utils, schema-registry) do (
    call :concat %BASE_DIR%/share/java/%%i/*
)

rem Log4j settings
IF ["%SCHEMA_REGISTRY_LOG4J_OPTS%"] EQU [""] (
    if exist %~dp0../../etc/schema-registry/log4j.properties (
        set SCHEMA_REGISTRY_LOG4J_OPTS=-Dlog4j.configuration=file:%~dp0../../etc/schema-registry/log4j.properties
    ) else (
        set SCHEMA_REGISTRY_LOG4J_OPTS=-Dlog4j.configuration=file:%BASE_DIR%/config/log4j.properties
    )
)

rem JMX settings
IF ["%SCHEMA_REGISTRY_JMX_OPTS%"] EQU [""] (
    set SCHEMA_REGISTRY_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false
)

rem JMX port to use
IF ["%JMX_PORT%"] NEQ [""] (
    set SCHEMA_REGISTRY_JMX_OPTS=%SCHEMA_REGISTRY_JMX_OPTS% -Dcom.sun.management.jmxremote.port=%JMX_PORT%
)

rem Which java to use
IF ["%JAVA_HOME%"] EQU [""] (
    set JAVA=java
) ELSE (
    set JAVA="%JAVA_HOME%/bin/java"
)

rem Memory options
IF ["%SCHEMA_REGISTRY_HEAP_OPTS%"] EQU [""] (
    set SCHEMA_REGISTRY_HEAP_OPTS=-Xmx512M
)

rem JVM performance options
IF ["%SCHEMA_REGISTRY_JVM_PERFORMANCE_OPTS%"] EQU [""] (
    set SCHEMA_REGISTRY_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true
)

set COMMAND=%JAVA% %SCHEMA_REGISTRY_HEAP_OPTS% %SCHEMA_REGISTRY_JVM_PERFORMANCE_OPTS% %SCHEMA_REGISTRY_JMX_OPTS% %SCHEMA_REGISTRY_LOG4J_OPTS% -cp %CLASSPATH% %SCHEMA_REGISTRY_OPTS% %*
%COMMAND%

goto :eof
:concat
IF ["%CLASSPATH%"] EQU [""] (
  set CLASSPATH="%1"
) ELSE (
  set CLASSPATH=%CLASSPATH%;"%1"
)
于 2019-04-15T17:34:57.010 回答
1

我已经成功地使用 cygwin 从 cmd.exe 运行了融合工具。

C:\>c:\cygwin64\bin\bash -l /cygdrive/c/confluent/4.0.0/bin/kafka-avro-console-consumer --bootstrap-server <my_server_name>:9092 --topic <my_topic> --property schema.registry.url=http://<my_schema_registry_url>:8081 >> tmp.txt
于 2018-01-08T22:02:51.320 回答
0

架构注册表 bat 文件的代码。另存为 schema-registry-start.bat


@echo off

%~dp0schema-registry-run-class.bat io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain %*

架构注册表属性文件应如下所示: 另存为 schema-registry.properties

listeners=http://10.91.31.169:8081
kafkastore.connection.url=10.91.31.169:2181
kafkastore.topic=_schemas
debug=true
于 2019-04-15T17:38:12.213 回答