alibaba / arthas

Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas
https://arthas.aliyun.com/
Apache License 2.0
35.57k stars 7.48k forks source link

AsyncProfiler error: No such file or directory #1672

Closed welyss closed 3 years ago

welyss commented 3 years ago
[INFO] arthas-boot version: 3.4.4
[INFO] arthas home: /tmp/arthas
[INFO] Try to attach process 32498
[INFO] Attach process 32498 success.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'

wiki      https://arthas.aliyun.com/doc
tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html
version   3.4.4
pid       32498
time      2021-01-19 16:58:27

通过命令:sudo -u tomcat -s /bin/bash -c "cd /tmp/;/usr/java/jdk1.7.0_55/bin/java -jar /tmp/arthas/arthas-boot.jar 32498" attach成功后:

  1. profiler start
  2. profiler stop

之后就会报这个错 我们环境tomcat账号是不可登录,tomcat是通过jsvc启动,不知道和这有没有关系,主要是不知道输出文件落哪里去了. 刚试了下如果profiler stop --file /tmp/xxxx.svg时是可以成功的

hengyunabc commented 3 years ago

试下重启进程,用最新版本arthas。默认情况下,会在应用的 working directory 建一个 arthas-output 目录,然后输出到里面。

如果应用本身没权限,也可能出错。检查下 ~/logs/arthas/arthas.log 。

welyss commented 3 years ago

用3.6版本试了下:

[INFO] arthas-boot version: 3.4.6
[DEBUG] Repo mirror:aliyun
[DEBUG] Java version is 1.7, only support http, set useHttp to true.
[INFO] arthas home: /tmp/arthas
[INFO] Try to attach process 32498
[DEBUG] Start arthas-core.jar args: [-jar, /tmp/arthas/arthas-core.jar, -pid, 32498, -core, /tmp/arthas/arthas-core.jar, -agent, /tmp/arthas/arthas-agent.jar]
[DEBUG] Found java: /usr/java/jdk1.7.0_55/jre/bin/java
[DEBUG] Found java: /usr/java/jdk1.7.0_55/jre/../bin/java
[DEBUG] Found tools.jar: /usr/java/jdk1.7.0_55/jre/../lib/tools.jar
[INFO] Attach process 32498 success.
[INFO] arthas-client connect 127.0.0.1 3658
[DEBUG] Start arthas-client.jar args: [127.0.0.1, 3658]
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'

wiki      https://arthas.aliyun.com/doc
tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html
version   3.4.4
pid       32498
time      2021-01-19 16:58:27

还是同样的错误,日志里的内容:

2021-01-19 17:54:47 [arthas-command-execute] ERROR c.t.a.c.c.monitor200.ProfilerCommand -AsyncProfiler error
java.io.IOException: No such file or directory
        at one.profiler.AsyncProfiler.execute0(Native Method)
        at one.profiler.AsyncProfiler.execute(AsyncProfiler.java:120)
        at com.taobao.arthas.core.command.monitor200.ProfilerCommand.execute(ProfilerCommand.java:315)
        at com.taobao.arthas.core.command.monitor200.ProfilerCommand.processStop(ProfilerCommand.java:429)
        at com.taobao.arthas.core.command.monitor200.ProfilerCommand.process(ProfilerCommand.java:374)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
        at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:385)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

感觉是arthas-output没有成功创建,“应用的working directory”是指tomcat的工作目录吗,tomcat用户不可登录但是工作目录权限应该是有的,有办法看到实际创建arthas-output时的完整路径吗,可能还是跟用户权限有关,不过指定文件也能用,问题倒是不大

jianhaiqing commented 5 months ago

是的, 给tomcat working directory 授权 tomcat 用户权限, 比如 working directory 是 /usr/local/tomcat, chown -R tomcat:tomcat /usr/local/tomcat