java - 来自 JVM 的 YourKit Java Profiler - 远程连接向导

标签 java linux ubuntu apache2 tomcat7

我做了什么:

  1. 我下载了适用于 Linux 的试用版 ( https://www.yourkit.com/download/ ) YourKit Java Profiler 并在我的 AWS 实例中进行了测试。
  2. 我正在尝试通过以下步骤通过远程连接向导启用分析/home/yourkit/yjp-2015-build-15078/bin/bin/yjp.sh -attach <PID>
  3. 我收到以下错误,

我得到的 - 错误:

[YourKit Java Profiler 2015 build 15078] Cannot create log file: /home/ubuntu/.yjp/log/yjp-2041.log
  To specify alternate log directory use startup option 'logdir'
15078 0.021: Command line:
  /home/yourkit/yjp-2015-build-15078/bin/../jre64/bin/java
  -Xmx4G
  -XX:+HeapDumpOnOutOfMemoryError
  -XX:OnError=/home/yourkit/yjp-2015-build-15078/bin/../bin/yjp.sh -on_error %p
  -jar
  /home/yourkit/yjp-2015-build-15078/bin/../lib/yjp.jar
  -attach
  1476
15078 0.021: Executable: /home/yourkit/yjp-2015-build-15078/jre64/bin/java
15078 0.021: uname:
  sysname: Linux
  release: 3.13.0-48-generic
  version: #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015
  machine: x86_64
15078 0.021: Linux; fast_thread_cpu_time=1; 64-bit process
15078 0.021: hid: 36022997176V9ZXX3UXV5UWZ513Z98931W 64-bit machine
15078 0.021: Today is 20151201
15078 0.021: full_build_stamp: 15078 201511161426
15078 0.021: Agent library path: /home/yourkit/yjp-2015-build-15078/bin/linux-x86-64/libyjpagent.so
15078 0.021:
---------------------------------------------------------------------
Product: YourKit Java Profiler 2015 build 15078
Build: 15078 on 201511161343
JDK: 1.8.0_65
VM: Java HotSpot(TM) 64-Bit Server VM
Vendor: Oracle Corporation
OS: Linux
OS version: 3.13.0-48-generic
OS arch: amd64
Date and time: Tue Dec 01 11:01:56 UTC 2015
Properties:
  awt.toolkit=sun.awt.X11.XToolkit
  file.encoding.pkg=sun.io
  file.encoding=UTF-8
  file.separator=/
  java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
  java.awt.printerjob=sun.print.PSPrinterJob
  java.class.path=/home/yourkit/yjp-2015-build-15078/bin/../lib/yjp.jar
  java.class.version=52.0
  java.endorsed.dirs=/home/yourkit/yjp-2015-build-15078/jre64/lib/endorsed
  java.ext.dirs=/home/yourkit/yjp-2015-build-15078/jre64/lib/ext:/usr/java/packages/lib/ext
  java.home=/home/yourkit/yjp-2015-build-15078/jre64
  java.io.tmpdir=/tmp
  java.library.path=/home/yourkit/yjp-2015-build-15078/bin/linux-x86-64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
  java.runtime.name=Java(TM) SE Runtime Environment
  java.runtime.version=1.8.0_65-b17
  java.specification.name=Java Platform API Specification
  java.specification.vendor=Oracle Corporation
  java.specification.version=1.8
  java.vendor.url.bug=http://bugreport.sun.com/bugreport/
  java.vendor.url=http://java.oracle.com/
  java.vendor=Oracle Corporation
  java.version=1.8.0_65
  java.vm.info=mixed mode
  java.vm.name=Java HotSpot(TM) 64-Bit Server VM
  java.vm.specification.name=Java Virtual Machine Specification
  java.vm.specification.vendor=Oracle Corporation
  java.vm.specification.version=1.8
  java.vm.vendor=Oracle Corporation
  java.vm.version=25.65-b01
  line.separator=

  os.arch=amd64
  os.name=Linux
  os.version=3.13.0-48-generic
  path.separator=:
  sun.arch.data.model=64
  sun.boot.class.path=/home/yourkit/yjp-2015-build-15078/jre64/lib/resources.jar:/home/yourkit/yjp-2015-build-15078/jre64/lib/rt.jar:/home/yourkit/yjp-2015-build-15078/jre64/lib/sunrsasign.jar:/home/yourkit/yjp-2015-build-15078/jre64/lib/jsse.jar:/home/yourkit/yjp-2015-build-15078/jre64/lib/jce.jar:/home/yourkit/yjp-2015-build-15078/jre64/lib/charsets.jar:/home/yourkit/yjp-2015-build-15078/jre64/lib/jfr.jar:/home/yourkit/yjp-2015-build-15078/jre64/classes
  sun.boot.library.path=/home/yourkit/yjp-2015-build-15078/jre64/lib/amd64
  sun.cpu.endian=little
  sun.cpu.isalist=
  sun.font.fontmanager=sun.awt.X11FontManager
  sun.io.unicode.encoding=UnicodeLittle
  sun.java.command=/home/yourkit/yjp-2015-build-15078/bin/../lib/yjp.jar -attach 1476
  sun.java.launcher=SUN_STANDARD
  sun.jnu.encoding=UTF-8
  sun.management.compiler=HotSpot 64-Bit Tiered Compilers
  sun.os.patch.level=unknown
  user.country=US
  user.dir=/home/yourkit/yjp-2015-build-15078/bin
  user.home=/home/ubuntu
  user.language=en
  user.name=ubuntu
  user.timezone=Etc/UTC
Environment:
  DERBY_HOME=/usr/lib/jvm/java-8-oracle/db
  HOME=/home/ubuntu
  J2REDIR=/usr/lib/jvm/java-8-oracle/jre
  J2SDKDIR=/usr/lib/jvm/java-8-oracle
  JAVA_HOME=/usr/lib/jvm/java-8-oracle
  LANG=en_US.UTF-8
  LD_LIBRARY_PATH=/home/yourkit/yjp-2015-build-15078/bin/linux-x86-64
  LESSCLOSE=/usr/bin/lesspipe %s %s
  LESSOPEN=| /usr/bin/lesspipe %s
  LOGNAME=ubuntu
  LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
  MAIL=/var/mail/ubuntu
  NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat
  OLDPWD=/home/ubuntu
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
  PWD=/home/yourkit/yjp-2015-build-15078/bin
  SHELL=/bin/bash
  SHLVL=1
  SSH_CLIENT=49.207.180.185 40292 22
  SSH_CONNECTION=49.207.180.185 40292 172.31.24.197 22
  SSH_TTY=/dev/pts/0
  TERM=xterm
  USER=ubuntu
  XDG_RUNTIME_DIR=/run/user/1000
  XDG_SESSION_ID=1
  XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
  _=./yjp.sh
---------------------------------------------------------------------


15078 0.022: com.yourkit.Main1: starting...
15078 0.022: com.yourkit.Main1: number of args: 2
15078 0.022: com.yourkit.Main1: arg = -attach
15078 0.022: com.yourkit.Main1: arg = 1476
15078 0.088: com.yourkit.Main1: oomeDumperStatus: 1
Attaching to process 1476 using default options
15078 0.100: com.yourkit.g.u.q: Process type: _64_BIT
15078 0.100: com.yourkit.g.u.q: Process path: /usr/lib/jvm/java-7-openjdk-amd64/bin/java
15078 0.104: com.yourkit.g.u.q: Trying to attach as to a 64-bit JVM:
  /home/yourkit/yjp-2015-build-15078/jre64/bin/java
  -Xbootclasspath/a:/home/yourkit/yjp-2015-build-15078/lib/tools.jar
  -Dfile.encoding=UTF-8
  -cp
  /home/yourkit/yjp-2015-build-15078/lib/yjp.jar
  com.yourkit.Attach
  1476
  /home/yourkit/yjp-2015-build-15078/bin/linux-x86-64/libyjpagent.so

15078 0.193: com.yourkit.g.u.q: Command failed:
  exit code: 3
  stdout:
    PID: 1476
    path_to_agent: /home/yourkit/yjp-2015-build-15078/bin/linux-x86-64/libyjpagent.so
    startupOptions:
    java.io.IOException: Operation not permitted
        at sun.tools.attach.LinuxVirtualMachine.sendQuitTo(Native Method)
        at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:91)
        at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
        at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
        at com.yourkit.Attach.main(a:94)

com.yourkit.runtime.PresentableException: java.io.IOException: Operation not permitted
        at com.yourkit.g.u.q.a(a:46)
        at com.yourkit.g.u.c.a(a:122)
        at com.yourkit.Main1.for(a:300)
        at com.yourkit.Main1.entry(a:320)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.yourkit.Main$2.run(a:21)

Attach to a running JVM failed.

Solution: start JVM with the profiler agent instead of attaching it to a running JVM:
https://www.yourkit.com/docs/java/help/running_with_profiler.jsp

注意:我的问题是,

  1. 需要安装步骤 Java Profiler for JVM。
  2. 如何通过远程连接。

最佳答案

你的套件:

1. You need to install yourkit both on local development machine and remote mahine that you wish to profile
2. On local dev machine : 
    a. Cd to bin and then execute ./yjp.sh  -> This will open a console to debug
3. On Remote server 
    a. Scp the yjp.tar file to remote machine. Untar it
    b. Cd to bin directory and attach the yourkit agent to the process you want to profile 
        i. This can be done : ./yjp.sh -attach -> And then select the process id you want to attach. That’s it
        ii. Or other way is ./yjp.sh -attach <PID>
    c. Open the specific port on which yjp agent is listening. Not the one application is listening (Usually the ports will be ranging from 10001 to blah blah)
    iptables -P INPUT ACCEPT 

4. On local dev yourkit software, click on "Connect to remote application"
Enter <hostIPaddress>:<port#ofYJP>

That’s it !! Profiler is now attached and you can debug :) Happy Profiling !!

关于java - 来自 JVM 的 YourKit Java Profiler - 远程连接向导,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34018901/

相关文章:

java - Ant 编译但不运行或创建 jar

c - 使用 perl XS 链接到 C 共享库

linux - 由 :Ambari Upgradation java. sql.SQLSyntaxErrorException: Unknown table 'hostcomponentstate' in information_schema 引起

linux - 我想从另一个脚本运行一个脚本,使用相同版本的 perl,并将 IO 重新路由到类似终端的文本框

ruby - 在 Ubuntu for Discourse 上安装 fast_xor Gem 时遇到问题

mysql - Vagrant Box - 使用 apt 安装 MySql 5.7

ubuntu - 阻止 apache cassandra 自动启动

java - 倒数计时器延迟 - Android

java - 使用 JCufft 进行实数到复数 FFT

java - Android Parcelable - 使用通用数据类型将数据读/写到 Parcel