Kafka Streams openjdk:8-alpine 的替代方案
Alternative to openjdk:8-alpine for Kafka Streams
我正在使用 openjdk:8-alpine 部署 Kafka Streams 应用程序。我正在使用 Windowing,它因以下错误而崩溃:
Exception in thread "app-4a382bdc55ae-StreamThread-1" java.lang.UnsatisfiedLinkError: /tmp/librocksdbjni94709417646402513.so: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /tmp/librocksdbjni94709417646402513.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.rocksdb.NativeLibraryLoader.loadLibraryFromJar(NativeLibraryLoader.java:78)
at org.rocksdb.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:56)
at org.rocksdb.RocksDB.loadLibrary(RocksDB.java:64)
at org.rocksdb.RocksDB.<clinit>(RocksDB.java:35)
at org.rocksdb.Options.<clinit>(Options.java:22)
at org.apache.kafka.streams.state.internals.RocksDBStore.openDB(RocksDBStore.java:116)
at org.apache.kafka.streams.state.internals.Segment.openDB(Segment.java:43)
at org.apache.kafka.streams.state.internals.Segments.getOrCreateSegment(Segments.java:91)
at org.apache.kafka.streams.state.internals.RocksDBSegmentedBytesStore.put(RocksDBSegmentedBytesStore.java:100)
at org.apache.kafka.streams.state.internals.RocksDBSessionStore.put(RocksDBSessionStore.java:122)
at org.apache.kafka.streams.state.internals.ChangeLoggingSessionBytesStore.put(ChangeLoggingSessionBytesStore.java:78)
at org.apache.kafka.streams.state.internals.ChangeLoggingSessionBytesStore.put(ChangeLoggingSessionBytesStore.java:33)
at org.apache.kafka.streams.state.internals.CachingSessionStore.putAndMaybeForward(CachingSessionStore.java:177)
at org.apache.kafka.streams.state.internals.CachingSessionStore.access[=11=]0(CachingSessionStore.java:38)
at org.apache.kafka.streams.state.internals.CachingSessionStore.apply(CachingSessionStore.java:88)
at org.apache.kafka.streams.state.internals.NamedCache.flush(NamedCache.java:142)
at org.apache.kafka.streams.state.internals.NamedCache.flush(NamedCache.java:100)
at org.apache.kafka.streams.state.internals.ThreadCache.flush(ThreadCache.java:127)
at org.apache.kafka.streams.state.internals.CachingSessionStore.flush(CachingSessionStore.java:193)
at org.apache.kafka.streams.state.internals.MeteredSessionStore.flush(MeteredSessionStore.java:169)
at org.apache.kafka.streams.processor.internals.ProcessorStateManager.flush(ProcessorStateManager.java:244)
at org.apache.kafka.streams.processor.internals.AbstractTask.flushState(AbstractTask.java:195)
at org.apache.kafka.streams.processor.internals.StreamTask.flushState(StreamTask.java:332)
at org.apache.kafka.streams.processor.internals.StreamTask.run(StreamTask.java:312)
at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208)
at org.apache.kafka.streams.processor.internals.StreamTask.commit(StreamTask.java:307)
at org.apache.kafka.streams.processor.internals.StreamTask.commit(StreamTask.java:297)
at org.apache.kafka.streams.processor.internals.AssignedTasks.apply(AssignedTasks.java:67)
at org.apache.kafka.streams.processor.internals.AssignedTasks.applyToRunningTasks(AssignedTasks.java:357)
at org.apache.kafka.streams.processor.internals.AssignedTasks.commit(AssignedTasks.java:347)
at org.apache.kafka.streams.processor.internals.TaskManager.commitAll(TaskManager.java:403)
at org.apache.kafka.streams.processor.internals.StreamThread.maybeCommit(StreamThread.java:994)
at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:811)
at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:750)
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:720)
搜索上述问题,我遇到了 https://issues.apache.org/jira/browse/KAFKA-4988。但这并没有帮助。
因此,Alpine 使用 musl-libc,但 RocksDB 不支持它。
向 RocksDB 添加对 musl-libc 的支持的问题:facebook/rocksdb#3143.
问题:是否有任何 openjdk docker 图像可以用来制作我的 Kafka Stream 应用程序 运行 并且不会给 rocksdb 带来问题?
Edit-1:我尝试了 RUN apk add --no-cache bash libc6-compat
,但它也失败并出现以下错误:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000000011e336, pid=1, tid=0x00007fc6a3cc8ae8
#
# JRE version: OpenJDK Runtime Environment (8.0_181-b13) (build 1.8.0_181-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.181-b13 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.9.0
# Distribution: Custom build (Tue Oct 23 11:27:22 UTC 2018)
# Problematic frame:
# C 0x000000000011e336
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
您链接的票证 https://issues.apache.org/jira/browse/KAFKA-4988 提供了很多关于问题的见解。
如前所述,RocksDB 似乎与 musl libc 不兼容,因此需要 glibc。
安装 libc6-compact
可能不起作用:它在 musl libc 上提供了一个兼容层,它模仿 glibc 库结构并实现了一些缺失的功能,但这与安装 glibc 本身不同。 glibc 是一个复杂的实现,因此兼容性库和实际的 glibc 之间可能没有一对一的关联。请参阅 here 了解一些细微的 musl/glibc 差异。
看了工单评论,可能是有问题的库librocksdbjni.so
,依赖于libstdc++6.
因此,我会尝试以下操作(使用 openjdk:8-alpine
作为基础图像):
- 确保
libstdc++
软件包已安装;
- 手动安装 glibc,如此Dockerfile (a stripped down version of glibc Dockerfile by anapsix/docker-alpine-java).
对我有用的解决方案是将 docker 图像从 openjdk:8-alpine
更改为 adoptopenjdk/openjdk8:alpine-slim
。
adoptopenjdk/openjdk8:alpine-slim
glibc 兼容。
我是从 http://blog.gilliard.lol/2018/11/05/alpine-jdk11-images.html 那里知道这张图片的。
希望对大家有所帮助。
与其更改默认 docker 基础映像,不如为 Alpine 发行版构建 glibc。更好的是,您可以从 Sasha Gerrand's github page 获取预构建的 apk。这是我们添加到 Dockerfile 中的内容,以使其与他的预构建 apk 一起工作:
# # GLIBC - Kafka Dependency (RocksDB)
# Used by Kafka for default State Stores.
# glibc's apk was built for Alpine Linux and added to our repository
# from this source: https://github.com/sgerrand/alpine-pkg-glibc/
ARG GLIBC_APK=glibc-2.30-r0.apk
COPY ${KAFKA_DIR}/${GLIBC_APK} opt/
RUN apk add --no-cache --allow-untrusted opt/${GLIBC_APK}
# C++ Std Lib - Kafka Dependency (RocksDB)
RUN apk add --no-cache libstdc++
关于 https://issues.apache.org/jira/browse/KAFKA-4988 中的 Kafka Streams 和 Alpine linux 不兼容的已知问题。
对于那些使用 Java 11 的人,adoptopenjdk/openjdk11:alpine-slim
对我来说很好用。
另一种解决方案是仍然使用 openjdk:11-jdk-alpine 图像作为基础图像,然后手动安装 snappy-java lib
FROM openjdk:11-jdk-alpine
RUN apk update && apk add --no-cache gcompat
...
我正在使用 openjdk:8-alpine 部署 Kafka Streams 应用程序。我正在使用 Windowing,它因以下错误而崩溃:
Exception in thread "app-4a382bdc55ae-StreamThread-1" java.lang.UnsatisfiedLinkError: /tmp/librocksdbjni94709417646402513.so: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /tmp/librocksdbjni94709417646402513.so)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at org.rocksdb.NativeLibraryLoader.loadLibraryFromJar(NativeLibraryLoader.java:78)
at org.rocksdb.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:56)
at org.rocksdb.RocksDB.loadLibrary(RocksDB.java:64)
at org.rocksdb.RocksDB.<clinit>(RocksDB.java:35)
at org.rocksdb.Options.<clinit>(Options.java:22)
at org.apache.kafka.streams.state.internals.RocksDBStore.openDB(RocksDBStore.java:116)
at org.apache.kafka.streams.state.internals.Segment.openDB(Segment.java:43)
at org.apache.kafka.streams.state.internals.Segments.getOrCreateSegment(Segments.java:91)
at org.apache.kafka.streams.state.internals.RocksDBSegmentedBytesStore.put(RocksDBSegmentedBytesStore.java:100)
at org.apache.kafka.streams.state.internals.RocksDBSessionStore.put(RocksDBSessionStore.java:122)
at org.apache.kafka.streams.state.internals.ChangeLoggingSessionBytesStore.put(ChangeLoggingSessionBytesStore.java:78)
at org.apache.kafka.streams.state.internals.ChangeLoggingSessionBytesStore.put(ChangeLoggingSessionBytesStore.java:33)
at org.apache.kafka.streams.state.internals.CachingSessionStore.putAndMaybeForward(CachingSessionStore.java:177)
at org.apache.kafka.streams.state.internals.CachingSessionStore.access[=11=]0(CachingSessionStore.java:38)
at org.apache.kafka.streams.state.internals.CachingSessionStore.apply(CachingSessionStore.java:88)
at org.apache.kafka.streams.state.internals.NamedCache.flush(NamedCache.java:142)
at org.apache.kafka.streams.state.internals.NamedCache.flush(NamedCache.java:100)
at org.apache.kafka.streams.state.internals.ThreadCache.flush(ThreadCache.java:127)
at org.apache.kafka.streams.state.internals.CachingSessionStore.flush(CachingSessionStore.java:193)
at org.apache.kafka.streams.state.internals.MeteredSessionStore.flush(MeteredSessionStore.java:169)
at org.apache.kafka.streams.processor.internals.ProcessorStateManager.flush(ProcessorStateManager.java:244)
at org.apache.kafka.streams.processor.internals.AbstractTask.flushState(AbstractTask.java:195)
at org.apache.kafka.streams.processor.internals.StreamTask.flushState(StreamTask.java:332)
at org.apache.kafka.streams.processor.internals.StreamTask.run(StreamTask.java:312)
at org.apache.kafka.streams.processor.internals.StreamsMetricsImpl.measureLatencyNs(StreamsMetricsImpl.java:208)
at org.apache.kafka.streams.processor.internals.StreamTask.commit(StreamTask.java:307)
at org.apache.kafka.streams.processor.internals.StreamTask.commit(StreamTask.java:297)
at org.apache.kafka.streams.processor.internals.AssignedTasks.apply(AssignedTasks.java:67)
at org.apache.kafka.streams.processor.internals.AssignedTasks.applyToRunningTasks(AssignedTasks.java:357)
at org.apache.kafka.streams.processor.internals.AssignedTasks.commit(AssignedTasks.java:347)
at org.apache.kafka.streams.processor.internals.TaskManager.commitAll(TaskManager.java:403)
at org.apache.kafka.streams.processor.internals.StreamThread.maybeCommit(StreamThread.java:994)
at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:811)
at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:750)
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:720)
搜索上述问题,我遇到了 https://issues.apache.org/jira/browse/KAFKA-4988。但这并没有帮助。
因此,Alpine 使用 musl-libc,但 RocksDB 不支持它。 向 RocksDB 添加对 musl-libc 的支持的问题:facebook/rocksdb#3143.
问题:是否有任何 openjdk docker 图像可以用来制作我的 Kafka Stream 应用程序 运行 并且不会给 rocksdb 带来问题?
Edit-1:我尝试了 RUN apk add --no-cache bash libc6-compat
,但它也失败并出现以下错误:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000000000011e336, pid=1, tid=0x00007fc6a3cc8ae8
#
# JRE version: OpenJDK Runtime Environment (8.0_181-b13) (build 1.8.0_181-b13)
# Java VM: OpenJDK 64-Bit Server VM (25.181-b13 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.9.0
# Distribution: Custom build (Tue Oct 23 11:27:22 UTC 2018)
# Problematic frame:
# C 0x000000000011e336
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
您链接的票证 https://issues.apache.org/jira/browse/KAFKA-4988 提供了很多关于问题的见解。
如前所述,RocksDB 似乎与 musl libc 不兼容,因此需要 glibc。
安装 libc6-compact
可能不起作用:它在 musl libc 上提供了一个兼容层,它模仿 glibc 库结构并实现了一些缺失的功能,但这与安装 glibc 本身不同。 glibc 是一个复杂的实现,因此兼容性库和实际的 glibc 之间可能没有一对一的关联。请参阅 here 了解一些细微的 musl/glibc 差异。
看了工单评论,可能是有问题的库librocksdbjni.so
,依赖于libstdc++6.
因此,我会尝试以下操作(使用 openjdk:8-alpine
作为基础图像):
- 确保
libstdc++
软件包已安装; - 手动安装 glibc,如此Dockerfile (a stripped down version of glibc Dockerfile by anapsix/docker-alpine-java).
对我有用的解决方案是将 docker 图像从 openjdk:8-alpine
更改为 adoptopenjdk/openjdk8:alpine-slim
。
adoptopenjdk/openjdk8:alpine-slim
glibc 兼容。
我是从 http://blog.gilliard.lol/2018/11/05/alpine-jdk11-images.html 那里知道这张图片的。
希望对大家有所帮助。
与其更改默认 docker 基础映像,不如为 Alpine 发行版构建 glibc。更好的是,您可以从 Sasha Gerrand's github page 获取预构建的 apk。这是我们添加到 Dockerfile 中的内容,以使其与他的预构建 apk 一起工作:
# # GLIBC - Kafka Dependency (RocksDB)
# Used by Kafka for default State Stores.
# glibc's apk was built for Alpine Linux and added to our repository
# from this source: https://github.com/sgerrand/alpine-pkg-glibc/
ARG GLIBC_APK=glibc-2.30-r0.apk
COPY ${KAFKA_DIR}/${GLIBC_APK} opt/
RUN apk add --no-cache --allow-untrusted opt/${GLIBC_APK}
# C++ Std Lib - Kafka Dependency (RocksDB)
RUN apk add --no-cache libstdc++
关于 https://issues.apache.org/jira/browse/KAFKA-4988 中的 Kafka Streams 和 Alpine linux 不兼容的已知问题。
对于那些使用 Java 11 的人,adoptopenjdk/openjdk11:alpine-slim
对我来说很好用。
另一种解决方案是仍然使用 openjdk:11-jdk-alpine 图像作为基础图像,然后手动安装 snappy-java lib
FROM openjdk:11-jdk-alpine
RUN apk update && apk add --no-cache gcompat
...