jprofiler監聽遠程linux上的tomcat

注意事項

  • jprofiler在linux上的版本要和在監聽機器上的版本一致。
  • 在被監聽的程序中加入jvm運行參數
    -agentpath:/opt/jprofiler9/bin/linux-x64/libjprofilerti.so=port={port},nowait
  • 以jprofiler 9.2.1 爲例

客戶端下載 jprofiler 9.2.1

打開網址https://www.ej-technologies.com/download/jprofiler/version_92 選擇相應的系統版本下載安裝。

服務端下載profiler 9.2.1

下載linux rpm版本, 使用wget命令下載。

# wget https://download-keycdn.ej-technologies.com/jprofiler/jprofiler_linux_9_2_1.rpm

運行rpm 命令進行安裝

# rpm -vsh jprofiler_linux_9_2_1.rpm

安裝完後,目錄在/opt/jprofiler9
運行命令 /opt/jprofiler9/bin/jpenable

運行tomcat

修改tomcat的catalina.sh文件, 加入一段代碼

CATALINA_OPTS=" -agentpath:/opt/jprofiler9/bin/linux-x64/libjprofilerti.so=port=10001,nowait"

10001是jprofiler的監聽端口

啓動tomcat, 查看{tomcat}/logs/catalina.out,一般會出現如下信息

...

26-Dec-2017 14:07:20.194 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
26-Dec-2017 14:07:20.194 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentpath:/opt/jprofiler9/bin/linux-x64/libjprofilerti.so=port=100
01,nowait
26-Dec-2017 14:07:20.194 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/servers/apache-tomcat-8.5.9

...

26-Dec-2017 14:07:31.811 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/servers/apache-tomcat-8.5.9/webapps/ROOT has finished in 11,348 ms
26-Dec-2017 14:07:31.818 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
26-Dec-2017 14:07:31.836 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
26-Dec-2017 14:07:31.838 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 11426 ms

客戶端監聽

運行jprofiles,出現可操作界面後, 打開創建Remote Integration界面。
Session –> Integration Wizards –> New Remote Integration
出現如下界面

Local or remote
這裏寫圖片描述
選擇 On a remote computer, 並且要選擇遠程計算機的操作系統,Next

Profiled JVM
這裏寫圖片描述
選擇jvm版本信息, Next

Startup mode
這裏寫圖片描述
選擇 Wait for a connection from the JProfiler GUI, Next

Remote address
這裏寫圖片描述
輸入被監聽機器的ip地址, Next

Remote Installation directory
這裏寫圖片描述
輸入linux機器(被監聽)上jprofiler的目錄路徑, Next

Choose profiling port
這裏寫圖片描述
輸入linux上tomcat中設置的jprofiler.port(監聽端口) 10001, Next

Perfom modifications
這裏寫圖片描述
Next

Finished
這裏寫圖片描述
Finish

Session Startup
這裏寫圖片描述
OK

連接中
這裏寫圖片描述

連接成功後, 過幾秒鐘, 就會出界監聽界面
這裏寫圖片描述

在linux上, 查看{tomcat}/logs/catalina.out,會出現如下信息
這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章