简体   繁体   English

UnsatisfiedLinkError:/tmp/snappy-1.1.4-libsnappyjava.so 加载共享库 ld-linux-x86-64.so.2 时出错:没有这样的文件或目录

[英]UnsatisfiedLinkError: /tmp/snappy-1.1.4-libsnappyjava.so Error loading shared library ld-linux-x86-64.so.2: No such file or directory

I am trying to run a Kafka Streams application in kubernetes.我正在尝试在 kubernetes 中运行 Kafka Streams 应用程序。 When I launch the pod I get the following exception:当我启动 pod 时,出现以下异常:

Exception in thread "streams-pipe-e19c2d9a-d403-4944-8d26-0ef27ed5c057-StreamThread-1"
java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-922ce96534a0-libsnappyjava.so: 
Error loading shared library ld-linux-x86-64.so.2: No such file or directory 
(needed by /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-922ce96534a0-libsnappyjava.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.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:179)
        at org.xerial.snappy.SnappyLoader.loadSnappyApi(SnappyLoader.java:154)
        at org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
        at org.xerial.snappy.SnappyInputStream.hasNextChunk(SnappyInputStream.java:435)
        at org.xerial.snappy.SnappyInputStream.read(SnappyInputStream.java:466)
        at java.io.DataInputStream.readByte(DataInputStream.java:265)
        at org.apache.kafka.common.utils.ByteUtils.readVarint(ByteUtils.java:168)
        at org.apache.kafka.common.record.DefaultRecord.readFrom(DefaultRecord.java:292)
        at org.apache.kafka.common.record.DefaultRecordBatch$1.readNext(DefaultRecordBatch.java:264)
        at org.apache.kafka.common.record.DefaultRecordBatch$RecordIterator.next(DefaultRecordBatch.java:563)
        at org.apache.kafka.common.record.DefaultRecordBatch$RecordIterator.next(DefaultRecordBatch.java:532)
        at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.nextFetchedRecord(Fetcher.java:1060)
        at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.fetchRecords(Fetcher.java:1095)
        at org.apache.kafka.clients.consumer.internals.Fetcher$PartitionRecords.access$1200(Fetcher.java:949)
        at org.apache.kafka.clients.consumer.internals.Fetcher.fetchRecords(Fetcher.java:570)
        at org.apache.kafka.clients.consumer.internals.Fetcher.fetchedRecords(Fetcher.java:531)
        at org.apache.kafka.clients.consumer.KafkaConsumer.pollOnce(KafkaConsumer.java:1146)
        at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1103)
        at org.apache.kafka.streams.processor.internals.StreamThread.pollRequests(StreamThread.java:851)
        at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:808)
        at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:774)
        at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:744)

Previously I have tried launching kafka and kafka-streams-app using docker containers and they worked perfectly fine.以前我曾尝试使用 docker 容器启动 kafka 和 kafka-streams-app,它们工作得很好。 This is the first time I am trying with Kubernetes.这是我第一次尝试使用 Kubernetes。

This is my DockerFile StreamsApp :这是我的DockerFile StreamsApp

FROM openjdk:8u151-jdk-alpine3.7

COPY /target/streams-examples-0.1.jar /streamsApp/

COPY /target/libs /streamsApp/libs

CMD ["java", "-jar", "/streamsApp/streams-examples-0.1.jar"]

What can I do to get past this issue?我该怎么做才能解决这个问题? Kindly help me out.请帮帮我。

EDIT:编辑:

/ # ldd /usr/bin/java 
    /lib/ld-musl-x86_64.so.1 (0x7f03f279a000)
Error loading shared library libjli.so: No such file or directory (needed by /usr/bin/java)
    libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f03f279a000)
Error relocating /usr/bin/java: JLI_Launch: symbol not found

In my case, install the missing libc6-compat didn't work.就我而言,安装缺少的 libc6-compat 不起作用。 Application still throw java.lang.UnsatisfiedLinkError .应用程序仍然抛出java.lang.UnsatisfiedLinkError

Then I find in the docker, /lib64/ld-linux-x86-64.so.2 exist and is a link to /lib/libc.musl-x86_64.so.1 , but /lib only contains ld-musl-x86_64.so.1 , not ld-linux-x86-64.so.2 .然后我在/lib64/ld-linux-x86-64.so.2发现, /lib64/ld-linux-x86-64.so.2存在并且是指向/lib/libc.musl-x86_64.so.1的链接,但/lib只包含ld-musl-x86_64.so.1 ,而不是ld-linux-x86-64.so.2

So I add a file named ld-linux-x86-64.so.2 linked to ld-musl-x86_64.so.1 in /lib dir and solve the problem.所以我在/lib目录中添加一个名为ld-linux-x86-64.so.2的文件链接到ld-musl-x86_64.so.1并解决问题。

Dockerfile I use:我使用的 Dockerfile:

FROM openjdk:8-jre-alpine
COPY entrypoint.sh /entrypoint.sh
RUN apk update && \
  apk add --no-cache libc6-compat && \
  ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 && \
  mkdir /app && \
  chmod a+x /entrypoint.sh
COPY build/libs/*.jar /app
ENTRYPOINT ["/entrypoint.sh"]

In conclusion:综上所述:

RUN apk update && apk add --no-cache libc6-compat
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

Error message states that *libsnappyjava.so cannot find ld-linux-x86-64.so.2.错误消息指出 *libsnappyjava.so 找不到 ld-linux-x86-64.so.2。 This is a glibc dynamic loader, while Alpine image doesn't run with glibc.这是一个 glibc 动态加载器,而 Alpine 图像不与 glibc 一起运行。 You may try to get it running by installing libc6-compat package in your Dockerfile, eg:您可以尝试通过在 Dockerfile 中安装 libc6-compat 包来运行它,例如:

RUN apk update && apk add --no-cache libc6-compat

There are two solutions of this problem:这个问题有两种解决方案:

  1. You may use some other base image with pre-installed snappy-java lib.您可以使用其他一些带有预安装snappy-java库的基本映像。 For example openjdk:8-jre-slim works fine for me例如openjdk:8-jre-slim对我来说很好用

  2. And the other solution is to still use openjdk:8-jdk-alpine image as base one, but then install snappy-java lib manually:另一种解决方案是仍然使用openjdk:8-jdk-alpine镜像作为基础镜像,然后手动安装snappy-java lib:

FROM openjdk:8-jdk-alpine
RUN apk update && apk add --no-cache gcompat
...

If you are adding docker file through build.sbt then correct way to do it is如果您通过 build.sbt 添加 docker 文件,那么正确的做法是

dockerfile in docker := {
  val artifact: File = assembly.value
  val artifactTargetPath = s"/app/${artifact.name}"

  new Dockerfile {
    from("openjdk:8-jre-alpine")
    copy(artifact, artifactTargetPath)
    run("apk", "add", "--no-cache", "gcompat")
    entryPoint("java", "-jar", artifactTargetPath)
  }

installing gcompat will serve your purpose安装 gcompat 将达到您的目的

It seems strange, but looks like the docker image you use- openjdk:8u151-jdk-alpine3.7 is inconsistent, and some dynamically loaded objects are not included into the package, or you need to run “ldconfig -v” in this image to update map of the shared objects, or, at last, there is /etc/ld.so.conf with the paths to places where OS is looking for .so objects.看起来很奇怪,但是看起来你使用的docker镜像-openjdk:8u151-jdk-alpine3.7不一致,有些动态加载的对象没有包含在包中,或者你需要在这个镜像中运行“ldconfig -v”更新共享对象的映射,或者,最后,有 /etc/ld.so.conf 包含操作系统正在寻找 .so 对象的位置的路径。 Please consider using another docker image providing java binary if you do not want to lose time on debugging it.如果您不想浪费时间调试它,请考虑使用另一个提供 java 二进制文件的 docker 镜像。 Last but not least, ask for a remedy on alpine forum.最后但并非最不重要的一点是,在 alpine 论坛上寻求补救措施。

I have implemented a docker image with which I run a Spring Boot microservice with a Kafka Strean Topology working perfectly.我已经实现了一个 docker 镜像,我用它运行了一个 Spring Boot 微服务,并且 Kafka Stean 拓扑完美地工作。

Here I share the Dockerfile file.这里我分享Dockerfile文件。

FROM openjdk:8-jdk-alpine
# Add Maintainer Info
LABEL description="Spring Boot Kafka Stream IoT Processor"
# Args for image
ARG PORT=8080

RUN apk update && apk upgrade && apk add --no-cache gcompat
RUN ln -s /bin/bash /usr/bin
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app


COPY resources/wait-for-it.sh  wait-for-it.sh
COPY target/iot_processor.jar app.jar

RUN dos2unix wait-for-it.sh
RUN chmod +x wait-for-it.sh
RUN uname -a
RUN pwd
RUN ls -al

EXPOSE ${PORT}

CMD ["sh", "-c", "echo 'waiting for 300 seconds for kafka:9092 to be accessable before 
starting application' && ./wait-for-it.sh -t 300 kafka:9092 -- java -jar app.jar"]

Hope it can help someone希望它可以帮助某人

in docker with alpine kernel在带有 alpine 内核的 docker 中

run apk update && apk add --no-cache libc6-compat gcompat save my life运行apk update && apk add --no-cache libc6-compat gcompat拯救我的生命

I don't need to add libc6-compat in dockerFile我不需要在 dockerFile 中添加 libc6-compat
Because the file /lib/libc.musl-x86_64.so.1 exist in my container因为文件 /lib/libc.musl-x86_64.so.1 存在于我的容器中

In dockerFile add only在 dockerFile 中只添加

run ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

My container don't have error when consumming msg on snappy compressing我的容器在快速压缩时消耗 msg 时没有错误

Exception in thread "streams-pipe-e19c2d9a-d403-4944-8d26-0ef27ed5c057-StreamThread-1"
java.lang.UnsatisfiedLinkError: /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd- 
922ce96534a0-libsnappyjava.so: 
Error loading shared library ld-linux-x86-64.so.2: No such file or directory 
(needed by /tmp/snappy-1.1.4-5cec5405-2ce7-4046-a8bd-922ce96534a0-libsnappyjava.so)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)

暂无
暂无

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

相关问题 qemu-x86_64:无法打开&#39;/lib/ld-musl-x86_64.so.1&#39;:没有这样的文件或目录 - qemu-x86_64: Could not open '/lib/ld-musl-x86_64.so.1': No such file or directory 加载共享库 libstdc++.so.6 时出错:没有这样的文件或目录(需要) - Error loading shared library libstdc++.so.6: No such file or directory (needed by) java.lang.UnsatisfiedLinkError / tmp / javacpp94368173067 / libopencv_core.so.2.4:无法打开共享对象文件:无此类文件或目录 - java.lang.UnsatisfiedLinkError /tmp/javacpp94368173067/ libopencv_core.so.2.4: cannot open shared object file: No such file or directory 在Android应用程序上加载现有共享库(.so)时出错(找不到unsatisfiedlinkerror本机方法) - Error loading existing shared library (.so) on Android app (unsatisfiedlinkerror native method not found) UnsatisfiedLinkError:在资源路径 (.) 中找不到本机库 (com/sun/jna/android-x86-64/libjnidispatch.so) - UnsatisfiedLinkError: Native library (com/sun/jna/android-x86-64/libjnidispatch.so) not found in resource path (.) 加载共享库时出错:libX11.so.6:无法打开共享对象文件:Linux docker容器中没有此类文件或目录 - error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory in linux docker container 在资源路径中找不到本机库(linux-x86-64 / libtesseract.so) - Native library (linux-x86-64/libtesseract.so) not found in resource path Tomcat中的共享JNI库(.so) - UnsatisfiedLinkError - Shared JNI library (.so) in Tomcat - UnsatisfiedLinkError spark 返回错误 libsnappyjava.so:无法从共享对象映射段:不允许操作 - spark returns error libsnappyjava.so: failed to map segment from shared object: Operation not permitted java.lang.UnsatisfiedLinkError:dlopen在64位而不是32位上失败,而.so应该在x86中构建 - java.lang.UnsatisfiedLinkError: dlopen failed 64-bit instead of 32-bit while .so should be built in x86
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM