Chinaunix首页 | 论坛 | 博客
  • 博客访问: 468117
  • 博文数量: 155
  • 博客积分: 2954
  • 博客等级: 少校
  • 技术积分: 1000
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-12 22:00
文章分类

全部博文(155)

文章存档

2014年(2)

2013年(5)

2012年(10)

2011年(33)

2010年(105)

我的朋友

分类: Java

2011-09-25 16:33:33

原文出处:http://blog.chenlb.com/2008/11/jprofiler-monitor-remote-linux-tomcat-server.html

写的web程序,有时候可能服务器挂了,要找bug,比较辛苦,有了监控工具就好多了。现记录下 jprofiler 远程监控tomcat的安装,与起步。

先来说我的环境:客户机,windows/java 1.6/jprofiler 5.1.2。可以看另一篇文章:jprofiler 试用 。
服务器:centos 5.1/java 1.6/jprofiler 5.1.2。下载linux版:

1、下载并安装,其实直接解压就得了。

[root@master local]# pwd /usr/local [root@master local]# wget [root@master local]# tar zxf jprofiler_linux_5_1_2.tar.gz

2、打开windows中的jprofiler,配置远程的session。

2.1、Shift+F1打开“QuickStart"对话框,选择“An application server, locally or remotely”,然后“Next”,如图:

2.2、选择服务器为:Apache Tomcat 6.x,Next,然后选择“On a remote computer”,再选择“Linux X86/AMD64”。

2.3、Next,输入远程机子IP地址,我这里是:Remote address 192.168.1.80。Next,输入远程jprofiler5的安装目录,我这里是Installation directory /user/local/jprofiler5

2.4、Next,输入本地tomcat的启动脚本,如:M:\apache-tomcat-6.0.18\bin\startup.sh。其实jprofiler是根据startup.sh生成新的启动脚本,新的脚本加了一些参数,如图。

2.5、Next,选择JVM版,如:JVM Vender Sun,Version 1.6.0,Mode hotspot。Next,选择监控远程服务器的端口,如:JProfiler port: 8849 default。

2.6、Next,选择启动方式,选择:Don't wait, startup immediately,如图:

选择了此项,下一步会让你选择配置文件同步方式,我选择“Manual synchroization”,并且输入配置文件在远程服务器的位置,如:/usr/local/jprofiler5,当然其它目录也一样的。

2.7、Next,后,会有 summary 配置信息列出,如图:

2.8、Next,选择“No, I will start the session later”,Finish。

3、服务器端配置,从 summary 的信息可以知道,C:\Documents and Settings\chenlb\.jprofiler5\config.xml 文件copy到/usr/local/jprofiler5目录下。把windows中的jprofiler5生成的tomcat的启动脚本放到服务器的tomcat/bin目录下,如我这里,把M:\apache-tomcat-6.0.18\bin\startup_jprofiler.sh 文件copy到/usr/local/tomcat-6.0.18/bin目录下。startup_jprofiler.sh 只加了启动参数让jprofiler可以去监控tomcat,打开startup_jprofiler.sh 文件看一下,在启动tomcat前面(即:exec "$PRGDIR"/"$EXECUTABLE" run "$@" 前面加)了:

  1. # The following lines have been added by the  
  2. # application server integration wizard of JProfiler  
  3.   
  4. LD_LIBRARY_PATH="/user/local/jprofiler5/bin/linux-x86:$LD_LIBRARY_PATH"  
  5. export LD_LIBRARY_PATH  
  6. CATALINA_OPTS="-agentlib:jprofilerti=port=8849,nowait,id=101,config=/usr/local/jprofiler5/config.xml -Xbootclasspath/a:/user/local/jprofiler5/bin/agent.jar $CATALINA_OPTS"  
  7. export CATALINA_OPTS  
  8.   
  9. # end of modifications  

其中,id=101是config里的session的id。

4、启动tomcat,然后,非常让人失望,报ERROR: Invalid license key.

[root@master tomcat-6.0.18]# bin/startup_jprofiler5.sh Using CATALINA_BASE: /usr/local/tomcat-6.0.18 Using CATALINA_HOME: /usr/local/tomcat-6.0.18 Using CATALINA_TMPDIR: /usr/local/tomcat-6.0.18/temp Using JRE_HOME: /usr/local/jdk1.6.0_10 [root@master tomcat-6.0.18]# tail logs/catalina.out JProfiler> 32-bit library JProfiler> Don't wait for frontend to connect. JProfiler> Using config file /usr/local/jprofiler5/config.xml (id: 101) JProfiler> Listening on port: 8849. JProfiler> Instrumenting native methods. JProfiler> Native library initialized JProfiler> Using dynamic instrumentation JProfiler> Time measurement: elapsed time JProfiler> CPU profiling enabled JProfiler> ERROR: Invalid license key. [root@master tomcat-6.0.18]#

想一想,windows下用的是破解的,破解是替换了dll文件的,而linux下没有破解,然后去官方注册一个key,可以免费用10天,注册地址:。

注册了新key后,在/usr/local/jprofiler5/config.xml文件licenseKey标签里改下。就得了。 :ok: 再启动tomcat正常了,

[root@master tomcat-6.0.18]# tail logs/catalina.out JProfiler> Using config file /usr/local/jprofiler5/config.xml (id: 101) JProfiler> Listening on port: 8849. JProfiler> Instrumenting native methods. JProfiler> Native library initialized JProfiler> Using dynamic instrumentation JProfiler> Time measurement: elapsed time JProfiler> CPU profiling enabled JProfiler> Hotspot compiler enabled JProfiler> Starting org/apache/catalina/startup/Bootstrap ...

5、好,现在可以本地windows的jprofiler监控远程tomcat了,打开本地jprofiler,Session->start center,然后双击“Apache Tomcat 6.x on 192.168.1.80”,如图

6、开始后,可以地址栏输入,再去看下jprofiler,恩,太可爱了,有动静,Thead views 如图:

那最下面的http-8080-1的线程就是打开上面的url后出现的。

好了,先写到这里,怎么用好就要靠自己了。

阅读(2532) | 评论(0) | 转发(0) |
0

上一篇:Spring AOP 样例二

下一篇:JProfiler试用手记

给主人留下些什么吧!~~