JAVA_HOME、PATH (如 /usr/local/jenkins/jdk1.6.0_37)。/usr/local/tomcat)。
# 1. 下載 Linux 版 (無 GUI 安裝包)
wget https://download-aws.ej-technologies.com/jprofiler/jprofiler_linux_8_0_4.tar.gz
# 2. 解壓
tar xf jprofiler_linux_8_0_4.tar.gz -C /usr/local/
# 產生 /usr/local/jprofiler8
# 3. 設置執行權限
chmod +x /usr/local/jprofiler8/bin/*.sh
在有圖形界面的機器 (Windows/Mac/Linux Desktop) 運行 JProfiler GUI 完成配置向導:
bin/startup.sh。startup_jprofiler.sh 腳本 (位於 Tomcat bin/ 目錄)。
# 1. 上傳生成的 startup_jprofiler.sh 到遠程 Tomcat bin 目錄
scp startup_jprofiler.sh user@remote:/usr/local/tomcat/bin/
# 2. 上傳 JProfiler agent 動態庫 (Linux x64)
scp -r /usr/local/jprofiler8/bin/linux-x64 user@remote:/usr/local/jprofiler8/bin/
# 3. 遠程服務器授權
chmod +x /usr/local/tomcat/bin/startup_jprofiler.sh
# 遠程服務器啟動 Tomcat (帶 JProfiler agent)
cd /usr/local/tomcat/bin
./startup_jprofiler.sh
# 本地 JProfiler GUI 連接
# Session → Attach to Running JVM → Remote → 輸入 IP:8849
#!/bin/sh
# JProfiler agent 路徑 (需與遠程服務器實際路徑一致)
JPROFILER_AGENT_PATH="/usr/local/jprofiler8/bin/linux-x64/libjprofilerti.so"
# JVM 參數注入
JAVA_OPTS="$JAVA_OPTS -agentpath:$JPROFILER_AGENT_PATH=port=8849,nowait"
# 原有啟動邏輯
exec "$CATALINA_HOME/bin/catalina.sh" start "$@"
| 現象 | 原因 | 解決 |
|---|---|---|
| 連接超時 | 防火牆阻擋 8849 端口 | firewall-cmd --add-port=8849/tcp --permanent && firewall-cmd --reload |
| Agent 加載失敗 | libjprofilerti.so 路徑錯誤或架構不匹配 (x64 vs aarch64) | 檢查 uname -m 對應上傳正確 agent 目錄 |
| Tomcat 啟動卡住 | agent 參數 nowait 缺失,JProfiler 等待 GUI 連接 | 確保 agentpath 含 nowait 或 GUI 先啟動連接 |
| 版本不兼容 | JProfiler 8 不支持 JDK 11+ | 升級 JProfiler 11+ 或降級 JDK 8 |
ssh -L 8849:localhost:8849 user@remote,本地連接 localhost:8849。