DolphinScheduler集成Arthas实现接口调用监控,提升调度任务可靠性 ...

立山  金牌会员 | 2024-11-6 08:55:07 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 913|帖子 913|积分 2739

本文介绍了在Apache DolphinScheduler中嵌入Arthas的方法,以实现对接口调用的监控。Arthas是一款强盛的 Java诊断工具,可以或许帮助开辟者实时查看应用步伐的运行状态、性能瓶颈和方法调用情况。在DolphinScheduler中集成Arthas,可以方便地捕获任务调度时的关键调用信息,实时发现并解决性能问题,提高体系的稳固性。本文将具体说明怎样在DolphinScheduler环境下启动Arthas,监控特定接口的调用,并分析收集到的性能数据,从而提升任务调度的可靠性和可维护性。
手动安装
  1. https://arthas.aliyun.com/download/latest_version?mirror=aliyun
  2. arthas-packaging-3.7.2-bin.zip
  3. cp arthas-packaging-3.7.2-bin.zip /opt/arthas
  4. cd /opt/arthas
  5. unzip arthas-packaging-3.7.2-bin.zip
  6. java -jar arthas-boot.jar
  7. 选择对应的进程号
复制代码
报错解决

报错1
  1. [ERROR] Start arthas failed, exception stack trace:
  2. com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
  3.         at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
  4.         at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
  5.         at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:250)
  6.         at com.taobao.arthas.core.Arthas.attachAgent(Arthas.java:102)
  7.         at com.taobao.arthas.core.Arthas.<init>(Arthas.java:27)
  8.         at com.taobao.arthas.core.Arthas.main(Arthas.java:161)
复制代码
解决 :
  1. 进入 ${DOLPINSCHEUDLER_HOME}/api-server/bin下,在 jvm_args_env.sh 中添加如下 :
  2. -XX:+StartAttachListener
复制代码
报错2
  1. Picked up JAVA_TOOL_OPTIONS:
  2. java.io.IOException: well-known file /tmp/.java_pid731688 is not secure: file should be owned by the current user (which is 0) but is owned by 989
  3.         at sun.tools.attach.LinuxVirtualMachine.checkPermissions(Native Method)
  4.         at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:117)
  5.         at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
  6.         at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:250)
  7.         at com.taobao.arthas.core.Arthas.attachAgent(Arthas.java:102)
  8.         at com.taobao.arthas.core.Arthas.<init>(Arthas.java:27)
  9.         at com.taobao.arthas.core.Arthas.main(Arthas.java:161)
  10. [ERROR] Start arthas failed, exception stack trace:
  11. [ERROR] attach fail, targetPid: 731688
复制代码
解决
  1. arthas启动的服务和dolpinscheduler启动服务所属的用户要一样,不然有如上的报错
复制代码
Watch

Watch 用于监控方法的具体实验细节,如参数、返回值等
  1. watch org.apache.dolphinscheduler.api.controller.UsersController queryUserList returnObj
复制代码
  1. [arthas@731688]$ watch org.apache.dolphinscheduler.api.controller.UsersController queryUserList returnObj
  2. Press Q or Ctrl+C to abort.
  3. Affect(class count: 1 , method count: 1) cost in 126 ms, listenerId: 2
  4. method=org.apache.dolphinscheduler.api.controller.UsersController.queryUserList location=AtExit
  5. ts=2024-08-27 02:04:01; [cost=4.918943ms] result=@Result[
  6.     code=@Integer[0],
  7.     msg=@String[成功],
  8.     data=@PageInfo[PageInfo(totalList=[User(id=1, userName=admin, userPassword=null, email=825193156@qq.com, phone=, userType=ADMIN_USER, tenantId=1, state=1, tenantCode=hdfs, queueName=default, alertGroup=null, queue=default, timeZone=null, createTime=Fri Jul 19 04:19:31 GMT-05:00 2024, updateTime=Mon Aug 12 22:15:58 GMT-05:00 2024)], total=1, totalPage=1, pageSize=10, currentPage=1, pageNo=0)],
  9. ]
  10. method=org.apache.dolphinscheduler.api.controller.UsersController.queryUserList location=AtExit
  11. ts=2024-08-27 02:04:18; [cost=6.905345ms] result=@Result[
  12.     code=@Integer[0],
  13.     msg=@String[成功],
  14.     data=@PageInfo[PageInfo(totalList=[User(id=1, userName=admin, userPassword=null, email=825193156@qq.com, phone=, userType=ADMIN_USER, tenantId=1, state=1, tenantCode=hdfs, queueName=default, alertGroup=null, queue=default, timeZone=null, createTime=Fri Jul 19 04:19:31 GMT-05:00 2024, updateTime=Mon Aug 12 22:15:58 GMT-05:00 2024)], total=1, totalPage=1, pageSize=10, currentPage=1, pageNo=0)],
  15. ]
  16. method=org.apache.dolphinscheduler.api.controller.UsersController.queryUserList location=AtExit
  17. ts=2024-08-27 02:04:27; [cost=5.803269ms] result=@Result[
  18.     code=@Integer[0],
  19.     msg=@String[成功],
  20.     data=@PageInfo[PageInfo(totalList=[User(id=1, userName=admin, userPassword=null, email=825193156@qq.com, phone=, userType=ADMIN_USER, tenantId=1, state=1, tenantCode=hdfs, queueName=default, alertGroup=null, queue=default, timeZone=null, createTime=Fri Jul 19 04:19:31 GMT-05:00 2024, updateTime=Mon Aug 12 22:15:58 GMT-05:00 2024)], total=1, totalPage=1, pageSize=10, currentPage=1, pageNo=0)],
  21. ]
复制代码
Trace

Trace 用于监控方法调用的深度,包罗调用了哪些方法以及每个方法的实验时间。
  1. [arthas@973263]$ trace org.apache.dolphinscheduler.api.controller.UsersController queryUserList
  2. Press Q or Ctrl+C to abort.
  3. Affect(class count: 1 , method count: 1) cost in 319 ms, listenerId: 1
  4. `---ts=2024-08-27 10:33:08;thread_name=qtp1836984213-26;id=26;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@439f5b3d
  5.     `---[13.962731ms] org.apache.dolphinscheduler.api.controller.UsersController:queryUserList()
  6.         +---[0.18% 0.025123ms ] org.apache.dolphinscheduler.api.controller.UsersController:checkPageParams() #130
  7.         +---[0.09% 0.012549ms ] org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils:handleEscapes() #131
  8.         `---[96.47% 13.469876ms ] org.apache.dolphinscheduler.api.service.UsersService:queryUserList() #132
复制代码
Dump

heapdump arthas-output/dump.hprof 生成堆转储文件:
  1. [arthas@973263]$ heapdump arthas-output/dump.hprof
  2. Dumping heap to arthas-output/dump.hprof ...
  3. Heap dump file created
复制代码
使用MAT进行内存泄漏分析。
查看jvm内存变革

memory查看JVM内存
  1. [arthas@973263]$ memory
  2. Memory                                                         used                 total                max                  usage               
  3. heap                                                           485M                 900M                 900M                 53.91%               
  4. ps_eden_space                                                  277M                 327M                 358M                 77.61%               
  5. ps_survivor_space                                              61M                  61M                  61M                  99.98%               
  6. ps_old_gen                                                     146M                 512M                 512M                 28.54%               
  7. nonheap                                                        162M                 188M                 -1                   85.96%               
  8. code_cache                                                     11M                  32M                  240M                 4.89%               
  9. metaspace                                                      135M                 140M                 -1                   96.67%               
  10. compressed_class_space                                         14M                  15M                  1024M                1.43%               
  11. direct                                                         949K                 949K                 -                    100.00%              
  12. mapped                                                         0K                   0K                   -                    0.00%
复制代码
查看CPU使用率

dashboard 可以查看CPU使用率,查看是哪个线程的,通过 thread -n 线程id查看:

转载自Journey
原文链接:https://segmentfault.com/a/1190000045219355
本文由 白鲸开源 提供发布支持!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

立山

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表