Windows客戶端的JProfiler遠程監控Linux上的Tomcat
1.測試環境
服務器:CentOS release 5.4 x86_64(內核版本 2.6.18-164.el5),Tomcat6.0.18,Sun JDK Java(TM) SE Runtime Environment (build 1.6.0_07-b06),Jprofiler_linux_6_2_3 for linux(安裝包:jprofiler_linux_6_2_3.sh)
客戶端:Windows XP,JProfiler 6.2.3 for windows(安裝包:jprofiler_windows_6_2_3.exe)
2.JProfiler軟件下載地址 http://www.ej-technologies.com/
3.客戶端 JProfiler 安裝 略
4.服務器端 JProfiler 安裝:
把 jprofiler_linux_6_2_3.sh 上傳到到服務器,假設路徑爲 /opt/jprofiler
# cd /opt/jprofiler
# chmod +x *.sh
# ./jprofiler_linux_6_2_3.sh -c
按照提示來安裝,提示都很簡單,不在多說。安裝路徑選擇 /opt/jprofiler6
注意,這裏的 -c 意思是用字符方式來安裝,如果機器上沒有 X 則加上該參數.
5.客戶端連接配置
1). 運行 JProfiler 。第一次打開會有嚮導,忽略它。
2). 選擇 Session->Integration Wizard->New Remote Integratation
3). 選擇 On a remote computer;Platform of remote computer 選擇 Linux x86/AMD 64;Next
4). 輸入服務器 IP ;Next
5). 輸入服務器上的 jprofiler 的安裝路徑,如 /opt/jprofiler6 ;next
6). 選擇服務器的 JDK 環境,這裏是:Sun,1.6.0.07,hotspot;next
7). 輸入端口:這裏是默認值 8849;next
8). 選擇啓動模式:這裏選第一種 wait for a connection from the jprofiler GUI;next
9). 這裏會列出需要在服務器端做的配置:
6.服務器端的配置
(1)修改系統環境配置文件 /etc/profile ,增加
# JPROFILER CONF
JPROFILER_HOME=/opt/jprofiler6/bin/linux-x64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JPROFILER_HOME
(2)修改TOMCAT啓動文件catalina.sh,添加
JAVA_OPTS="$JAVA_OPTS -server -Xms4096m -Xmx4096m -XX:PermSize=256m -XX:MaxNewSize=512m -XX:MaxPermSize=512m -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler6/bin/agent.jar"
8.啓動客戶端軟件
點擊jprofiler菜單 session>start center>Open Session
Available session configurations中列出了剛纔配置的連接,選中使用就OK了!!
9.The log of tomcat which is $CATALINA_HOME/logs/catalina.out will show:
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
JProfiler> Hotspot compiler enabled
JProfiler> Starting org/apache/catalina/startup/Bootstrap
10.當中斷JProfiler連接時
The log of tomcat which is $CATALINA_HOME/logs/catalina.out will show:
JProfiler> Disconnected. Waiting for reconnection.
JProfiler> Listening on port: 8849.
參考:http://hi.baidu.com/xuwanbest/blog/item/605f9f3335f05e46ac4b5f07.html
JVM optimization : http://blog.chinaunix.net/space.php?uid=16974460&do=blog&id=359566