来源于xuwanbest的博客
 
所谓“工欲善其事,必先利其器”,好的工具确能起到事半工倍的作用。我用到的最多的就两个JConsole 和JProfiler 。JConsole监控系统内存变化情况,如果有内存溢出的话,垃圾回收将会呈现锯齿状。发现问题以后,使用JProfiler,在小压力(或无压力)的情况下监控对象变化,定位内存溢出原因。
 
JProfiler是一款Java的性能监控工具。可以查看当前应用的对象、对象引用、内存、CPU使用情况、线程、线程运行情况(阻塞、等待等),同时可以查找应用内存使用得热点,即:哪个对象占用的内存比较多;或者CPU热点,即:哪儿方法占用的较大得CPU资源。我使用的是4.3.2版本,以前试用过3**版本,不过那个bug比较多,容易死,4**版本稳定多了。
 
有了上面那些信息对于系统的调优会有很大帮助。这里提供有几篇文章供参考:获取、介绍,简单入门,使用JProfiler解决实际问题。这几篇文章基本介绍了常见东西了,下面说点心得。
 
1. JProfiler监控是要消耗系统资源的,所以一般情况下不要用于性能测试时候的监控。
2. 如果要用于相对大压力情况下,可以有选择的打开监控项,不用所有都打开。主要有两个,一个是内存监控,打开的情况下可以查找内存分配热点。一个是CPU监控,打开的情况下可以查看CPU使用热点。
 
 
如图所示,红笔标注部分。如果两个都关闭的话,还是可以跑一定压力的,同时还可以监控对象数量。
1. 个人认为最好用的(也是用的最多的)是查询当前的对象的数量。数量监控很重要,如果你使用了单例,那么你只会看到有一个对象存在,如果多了就说明程序有问题了。同样,如果应用进行一系列操作,检查一下该销毁的对象是否还继续存在,如果没有释放,就得考虑是否存在内存溢出了。
2. JProfiler还提供了一个比较好的检查内存溢出得工具。他可以查找某个对象的引用情况,即:当你发现某个该释放掉的对象没有释放,就可以看一下哪个实例在引用它,找到了根即找到了溢出点。
3. 具体操作如下:在 “Memory Views”界面中右键选择你要监控的对象,选择第一项“Take Heap Snapshot for Selection”,选择完成后会进入“Heap Walker”界面,界面下面提供几个功能,选择“References”即可 。如图:
 
 
 
4. JProfiler提供不同的观察粒度,提供对类的监控、对包的监控、对J2EE组件的监控,同时过滤器也比较好用,直接定位你关注的包或类即可。
5. JProfiler的监控可能与应用之间存在一定时间差,所以有些时候需要等待刷新,才能显示正确系统情况。
 
Windows客户端的JProfiler远程监控Linux上的Tomcat
 
1.测试环境
服务器:RedHat Linux 3.4.3-9.EL4(内核版本 2.6.9-5.EL),Tomcat5.5.20,Sun JDK 1.5.0_09,JProfiler 4.3.2 for linux(安装包:jprofiler_linux_4_3_2.sh)
客户端:Windows XP,JProfiler 4.3.2 for windows(安装包:jprofiler_windows_4_3_2.exe)
 
2.JProfiler软件下载地址 http://www.ej-technologies.com/
 
3.客户端 JProfiler 安装 略
 
4.服务器端 JProfiler 安装:
把 jprofiler_linux_4.3.2.sh 上传到到服务器,假设路径为 /opt/jprofiler
1. # cd /opt/jprofiler
2. # chmod +x *.sh
3. # ./jprofiler_linux_4.3.2.sh -c
按照提示来安装,提示都很简单,不在多说。安装路径选择 /opt/jprofiler4
注意,这里的 -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/jprofiler4 ;next
6). 选择服务器的 JDK 环境,这里是:Sun,1.5.0,hotspot;next
7). 输入端口:这里是默认值 8849;next
8). 选择启动模式:这里选第一种 wait for a connection from the jprofiler GUI;next
9). 这里会列出需要在服务器端做的配置:
1. Integration type: [Generic application]
2. Selected JVM: Sun 1.5.0 (hotspot)
3. Startup mode: Wait for JProfiler GUI
(1) Please insert

-agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar

into the start command of your remote application right
after the java command.

(2) Please add

/opt/jprofiler4/bin/linux-x86

to the environment variable LD_LIBRARY_PATH.

A remote session named Remote application on 192.168.40.15 will be
created that connects to a running instance of the
remote application that is started with the modified start
command.
 
6.服务器端的配置
(1)修改系统环境配置文件 /etc/profile ,增加
1.
JPROFILER_HOME=/opt/jprofiler4/bin/linux-x86
2.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JPROFILER_HOME
(2)修改TOMCAT启动文件catalina.sh,添加-agentlib:jprofilerti=port=8849
-Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar 内容到CATALINA_OPTS中;
“-agentlib:jprofilerti=port=8849
-Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar ” 此内容由客户端软件生成
CATALINA_OPTS="$CATALINA_OPTS -Xms128m -Xmx128m $JPDA_OPTS
-agentlib:jprofilerti=port=8849
-Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar"
 
7.Reboot Linux and startup Tomcat using startup.sh;
The log of tomcat which is $CATALINA_HOME/logs/catalina.out will
show:
1.
JProfiler> Protocol version 23
2.
JProfiler> Using JVMTI
3.
JProfiler> 32-bit library
4.
JProfiler> Listening on port: 8849.
5.
JProfiler> Native library initialized
6.
JProfiler> Waiting for a connection from the JProfiler GUI
 
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:
1.
JProfiler> Using dynamic instrumentation
2.
JProfiler> Time measurement: elapsed time
3.
JProfiler> CPU profiling enabled
4.
JProfiler> Hotspot compiler enabled
5.
JProfiler> Starting org/apache/catalina/startup/Bootstrap
 
10.当中断JProfiler连接时
The log of tomcat which is $CATALINA_HOME/logs/catalina.out will
show:
1.
JProfiler> Disconnected. Waiting for reconnection.
2.
JProfiler> Listening on port: 8849. 

转载:JProfiler远程监控LINUX上的Tomcat过程细讲的更多相关文章

  1. Windows客户端的JProfiler远程监控Linux上的Tomcat

    1.测试环境 服务器:RedHat Linux 3.4.3-9.EL4(内核版本 2.6.9-5.EL),Tomcat5.5.20,Sun JDK 1.5.0_09,JProfiler 4.3.2 f ...

  2. JProfiler远程监控Linux上Tomcat的安装过程细讲(步骤非常详细!!!)

    JProfiler远程监控Linux上Tomcat的安装过程细讲(步骤非常详细!!!) 1.文件准备: 服务器:CentOS Linux release 7.3.1611 (Core)     Apa ...

  3. JConsole监控Linux上的Tomcat

    JConsole监控Linux上的Tomcat 从Java 5开始引入了 JConsole,来监控 Java 应用程序性能和跟踪 Java 中的代码.jconsole是JDK自带监控工具,只需要找到 ...

  4. Windows负载机JVM 远程监控Linux服务器下tomcat

    基本是跟着网上的操作进行的,除了遇到一个Local host name unknown的问题: 一.Linux服务器操作部分 服务器地址:10.64.111.68 首先配置JMX: 1.找到jdk目录 ...

  5. jprofile 远程监控linux上的jvm

    环境 客户端:win7+jprofiler_windows-x64_10_0_4.exe linux服务器:tomcat7+jdk1.7+jprofiler_linux_10_0_4.sh 一.客户端 ...

  6. 记一个菜鸟在Linux上部署Tomcat的随笔

    以前都只是在园子里找各种资料.文档.各种抱大腿,今天是第一次进园子里来添砖加瓦,实话说,都不知道整些啥东西上来,就把自己在Linux上搭建Tomcat的过程记录下来,人笨,请各位大虾们勿喷. 虽然做开 ...

  7. 在linux上部署tomcat服务

    在linux上部署tomcat 1.安装JDK 2.下载tomcat http://tomcat.apache.org/download-70.cgi 3.上传到服务器,并解压 4.上传war包或者已 ...

  8. 在Linux上安装tomcat和JDK

    1.tomcat的安装 a.#cd download(进入download文件夹) b.#wget http://111.23.5.142:82/mirrors.hust.edu.cn/apache/ ...

  9. Linux上部署Tomcat+Nginx负载均衡

    前提:配置好了JDK. 我这里是vm上的linux虚拟机,可能不适用于所有情况. 一.Linux上配置Tomcat 1.下载地址:https://tomcat.apache.org/download- ...

随机推荐

  1. 什么是业务运维,企业如何实现互联网+业务与IT的融合

    业务运维并不是一个新概念,针对传统信息架构提出的业务服务管理就是把以业务为核心的IT系统与IT基础设施性能进行整合运维的解决方案.然而随着互联网+转型的不断推进,基础设施的智能化和广泛云化成为IT发展 ...

  2. ffmpeg 音频转换: use ffmpeg convert the audio from stereo to mono without changing the video part

    To convert the audio from stereo to mono without changing the video part, you can use FFmpeg: ffmpeg ...

  3. 安装android

    http://www.oschina.net/question/1463998_220998 http://www.cnblogs.com/zoupeiyang/p/4034517.html

  4. iOS网络请求之multipart/form-data提交数据

    multipart/form-data表单数据 在http网络请求中,post没有请求长度的限制,因为post把数据放在了body中,而不是像Get一样放在了浏览器的地址栏中(可以这么理解), 所以相 ...

  5. Be a new gentleman

    有人说:'生活是个大染缸',对于自制力不强的我深表无奈,时常自省的我虽然徘徊在层次边缘,但还是依着光明一点点靠近: 着装得体(改善消费观念,价值观) 讲个人卫生,保持公共环境卫生 女士优先 与人保持安 ...

  6. SVN和CVS的区别

    对版本控制就有了一定的理解,同时也应该知道SVN与CVS是比较流行的两款SCM工具.那么到底这两款工具有什么区别呢? 1.版本编号方面 例如,我们的版本库为A,其中有文件a,b,c. 在SVN中,新版 ...

  7. 利用Kinect将投影变得可直接用手操控

    Finally 总算是到了这一天了!假期里算法想不出来,或者被BUG折磨得死去活来的时候,总是YY着什么时候能心情愉快地坐在电脑前写一篇项目总结,今天总算是抽出时间来总结一下这神奇的几个月. 现在回过 ...

  8. easyui的getRows和appendRow方法使用结果记录

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. RancherOS Hyper-V 安装

    RancherOS Hyper-V 安装, Install to disk 打开 Hyper-V 管理界器, 新建虚拟机 输入名称和存储位置 选择一代 最低 1024M 配置网络 创建虚拟磁盘 设置启 ...

  10. 問題排查:类型“System.DateTime”的对象无法转换为类型“System.String”

    最近在擴充資料對接工具的功能 經常會遇到這個狀況 當然還有其他同類提示,例如 int/decimal 無法轉 System.String 等等 無獨有偶 這些錯誤幾乎都是在 DataTable 轉換成 ...