リモートホストでJava 8アプリケーションをオフラインでプロファイリングしようとしましたが、直接アクセスできません。(HadoopクラスターでのFlink YARNジョブ)。
JProfiler->セッション->統合ウィザード->新しいリモート統合->いくつかの手順を実行し、「プロファイリングエージェントでアーカイブを作成」を介して、Linux 64のJProfiler内からオフラインデバッグ用の関連JProfilerライブラリをエクスポートできました。その後、ディレクトリ構造全体に対して755を再帰的に設定して、その抽出されていないアーカイブをすべてのホストの/ JPROFILERに展開しました。
次に、2つのタイマートリガーを使用してホスト上にセッションを作成しました。1つは2分後にトラッキングをアクティブにし、もう1つは22分後にすべてのトラッキングを停止してスナップショットを保存します。私が接続しているSSH経由で任意のリモートホストに対してJProfiler GUIでこのセッションを実行すると、正常に動作しているようです。ステータスバーに、2分後に3つの記録が実行され、22分後に0つのレコードが実行されていることがわかります。しかし、GUIなしのオフラインプロファイリングでそのセッションを使用しようとすると、機能しません。
クラスターでのオフラインプロファイリングの場合、適切なオプションを使用してYARNアプリケーションを起動し、起動したJVMに以下が含まれることを確認しました。
-agentpath:/JPROFILER/jprofiler11/bin/linux-x64/libjprofilerti.so=offline,id=123,config=/JPROFILER/jprofiler_config.xml
セットする。これは正常に機能しているようです。YARNコンテナーログから、stderrに表示されます。
JProfiler> Protocol version 63
JProfiler> Java 8 detected.
JProfiler> Offline profiling mode.
JProfiler> 64-bit library
JProfiler> Using config file /JPROFILER/jprofiler_config.xml (id: 123)
JProfiler> Listening on port: 8849.
JProfiler> Enabling native methods instrumentation.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Using sampling (2 ms)
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
SLF4J: Class path contains multiple SLF4J bindings.
... Some SLF4J stuff, no more JProfiler or other messages ...
ただし、スナップショットファイルが何らかの形で保存されることはありません。両方のトリガーがまったくトリガーされない可能性があります(記録が開始されたか、スナップショットの保存が機能していないかを確認する方法はありません)。/ tmpにあるJVMプロセスの作業ディレクトリでスナップショットを見つけようとし、次のようにしてホスト全体を検索しました。
find / -iname "*flink-taskmanager-snapshot*" 2>/dev/null
しかし、何も見つかりませんでした。トリガーが何かをstderrに出力するように構成されているにもかかわらず、それ以上のメッセージがstderrに書き込まれませんでした。
トリガー/スナップショットが機能しない理由はありますか?JProfilerは問題なく初期化されているようです。次にjprofiler_config.xmlを示します。
<?xml version="1.0" encoding="UTF-8"?>
<config version="11.1">
<sessions>
<session id="123" name="Flink-TaskManager-JProfiler" type="remote" remoteType="ssh" timeout="5" jvmConfigurationId="100" samplingFrequency="2" recordArrayAlloc="false" compilationMode="manual" compilationTarget="1.8">
<filters>
<group type="exclusive" name="Default excludes" template="none">
<filter type="exclusive" name="$Proxy" />
<!-- ... stripped ... -->
<filter type="exclusive" name="workshop." />
</group>
</filters>
<triggers logTarget="stderr" logFile="">
<timer descriptionType="manual" manualDescription="Start recording" offsetTime="2" intervalTime="2" type="limited">
<actions>
<startRecording>
<cpu enabled="true" />
<allocation enabled="true" />
<thread enabled="true" />
<telemetry enabled="true" />
</startRecording>
<startCallTracer />
<startProbeRecording name="builtin.HttpClientProbe" events="true" />
<printMessage message="JProfiler: Start tracking" />
</actions>
</timer>
<timer descriptionType="manual" manualDescription="stop recording" offsetTime="22" intervalTime="22" type="limited">
<actions>
<stopRecording>
<cpu enabled="true" />
<allocation enabled="true" />
<thread enabled="true" />
<telemetry enabled="true" />
</stopRecording>
<stopCallTracer />
<stopProbeRecording name="builtin.HttpClientProbe" />
<saveSnapshot file="flink-taskmanager-snapshot" number="true" />
<printMessage message="JProfiler: stop recording and save snapshot..." />
</actions>
</timer>
</triggers>
<probes>
<probe name="builtin.TrackingInterceptor">
<id value="1" />
<id value="2" />
<id value="5" />
<id value="7" />
</probe>
</probes>
<ssh port="43490" verifyHosts="false">
<entry hostName="some-remote-for-tests" userName="yarn" authentication="key" keyFile="C:\Users\theo\.ssh\id_rsa" />
</ssh>
</session>
</sessions>
</config>
そして、これが私のJavaバージョンに関する出力です:
$ /usr/java/jdk1.8.0_181-cloudera/bin/java -XshowSettings:properties -version
Property settings:
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = ANSI_X3.4-1968
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.awt.printerjob = sun.print.PSPrinterJob
java.class.path = .
java.class.version = 52.0
java.endorsed.dirs = /usr/java/jdk1.8.0_181-cloudera/jre/lib/endorsed
java.ext.dirs = /usr/java/jdk1.8.0_181-cloudera/jre/lib/ext
/usr/java/packages/lib/ext
java.home = /usr/java/jdk1.8.0_181-cloudera/jre
java.io.tmpdir = /tmp
java.library.path = /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_181-b13
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.8
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.8.0_181
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.181-b13
line.separator = \n
os.arch = amd64
os.name = Linux
os.version = 3.10.0-1062.4.1.el7.x86_64
path.separator = :
sun.arch.data.model = 64
sun.boot.class.path = /usr/java/jdk1.8.0_181-cloudera/jre/lib/resources.jar
/usr/java/jdk1.8.0_181-cloudera/jre/lib/rt.jar
/usr/java/jdk1.8.0_181-cloudera/jre/lib/sunrsasign.jar
/usr/java/jdk1.8.0_181-cloudera/jre/lib/jsse.jar
/usr/java/jdk1.8.0_181-cloudera/jre/lib/jce.jar
/usr/java/jdk1.8.0_181-cloudera/jre/lib/charsets.jar
/usr/java/jdk1.8.0_181-cloudera/jre/lib/jfr.jar
/usr/java/jdk1.8.0_181-cloudera/jre/classes
sun.boot.library.path = /usr/java/jdk1.8.0_181-cloudera/jre/lib/amd64
sun.cpu.endian = little
sun.cpu.isalist =
sun.io.unicode.encoding = UnicodeLittle
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = ANSI_X3.4-1968
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.os.patch.level = unknown
user.country = US
user.dir = /var/lib/hadoop-yarn
user.home = /root
user.language = en
user.name = root
user.timezone =
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
私はそれを追跡しましたが、オフラインプロファイリングに関するJProfiler 11および11.1のバグです。
タイマーが無制限、つまり定期的にスケジュールされている場合、オフラインプロファイリングのすべてのタイマーとそのアクションは適切に機能します。XMLは次のようになります
<timer offsetTimeUnit="s" intervalTime="10" intervalTimeUnit="s">
<actions>
<printMessage message="JProfiler Debug working?" />
</actions>
</timer>
設定された実行回数を!= 1に設定すると、構成XMLは次のようになります。
<timer manualDescription="Start recording" offsetTime="30" offsetTimeUnit="s" intervalTime="30" intervalTimeUnit="s" type="limited" count="2">
<actions>
<printMessage message="JProfiler: Start tracking" />
</actions>
</timer>
ただし、繰り返し数が1に設定されている場合、おそらくそれがデフォルトであるため、JProfiler構成XMLは要素のcount
属性を格納しませんtimer
。その順番のオフラインプロファイラーは繰り返しを実行しませんが、JProfiler UIはトリガーを1回実行します。
結論:jprofiler_config.xmlを手動で編集し、count=1
属性として属性に追加timer
すると、ここで問題が解決します。うまくいけば、JProfilerはすぐにバグを修正するでしょう。私は彼らのホームページでバグを報告しました。
編集週末にバグを報告してからわずか4時間後に、バグ修正バージョンを受け取りました。コメントにあるように、JProfiler 11.1.1がこれを修正します。この投稿は、オフラインプロファイリング(FLink / YARNで)をセットアップする方法に関する短いチュートリアルとして、また、アップグレードのリマインダーとしてJProfiler 11.0を使用している人のために、ここに保管します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加