gpt4 book ai didi

docker - 如何将探查器附加到 docker 进程

转载 作者:行者123 更新时间:2023-12-01 15:01:50 25 4
gpt4 key购买 nike

我在 docker 容器中存在的作业服务器中面临内存泄漏问题。要分析导致问题的原因,我需要将 jprofiler 或 yourkit 附加到 docker 容器进程。我不知道该怎么做。有人可以解释一下吗?

最佳答案

您可以尝试关注 中的“Configure JProfiler 9.2 to profiling applications running in Docker containersAndrew Liu :

这将涉及使用以下内容完成您现有的 Dockerfile:

RUN wget http://download-keycdn.ej-technologies.com/jprofiler/jprofiler_linux_9_2.tar.gz -P /tmp/ &&\
tar -xzf /tmp/jprofiler_linux_9_2.tar.gz -C /usr/local &&\
rm /tmp/jprofiler_linux_9_2.tar.gz

ENV JPAGENT_PATH="-agentpath:/usr/local/jprofiler9/bin/linux-x64/libjprofilerti.so=nowait"
EXPOSE 8849

这将使您能够对正在运行的容器执行 bash:
docker exec -it [container-name] bash

cd /usr/local/jrofiler9/
bin/jpenable

Alternatively, if you want to enable JProfiler agent at your web server start up and wait for JProfiler GUI connecting from host, instead of putting "ENV JPAGENT_PATH="-agentpath:/usr/local/jprofiler9/bin/linux-x64/libjprofilerti.so=nowait"" in the Dockerfile. Add following line to the JAVA_OPTS. For tomcat, it will be CATALINA_OPTS.
Note: the config.xml will be the place to put your JProfiler license key.


JAVA_OPTS="$JAVA_OPTS -agentpath:/usr/local/jprofiler9/bin/linux-x64/libjprofilerti.so=port=8849,wait,config=/usr/local/jprofiler9/config.xml"

Now you are done at the docker container side. The container is ready to be attached to your JProfiler GUI. The steps below are to be done on the host machine.

  1. Download JProfiler 9.2 from https://www.ej-technologies.com/download/jprofiler/files and install it.
  2. Open JProfiler and open a new session by press Ctrl + N or Click 'New Session' in Session menu.
  3. Select 'Attach to profiled JVM (local or remote)' in Session Type section. Enter the IP address and 8849 as profiling port in Profiled JVM Settings section. Leave the other settings as default. Then click OK.

关于docker - 如何将探查器附加到 docker 进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41357427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com