有时web网站会在运行一段时间后,莫名死掉。于是用jdk自带的jconsole监控了一下,发现内存不断增加,cpu也会达到90%以上。于是去检查程序是否有代码造成死循环,或者内存溢出。最后是借助于jprofiler工具找到了错误原因。觉得在这方面jprofiler是个不错的工具。以下总结一下jprofiler的安装和基本用法。
1.测试环境
服务器:Linux 2.6.18-8el5 ,Tomcat6.0,Sun JDK 1.6,JProfiler 5.1.2for linux(安装包:jprofiler_linux_5.1.2.sh)
客户端:Windows XP,JProfiler5.1.2 for windows(安装包:jprofiler_windows_5_1_2.exe)
2.JProfiler软件下载地址 http://www.ej-technologies.com/
3.客户端 JProfiler 安装 略
4.服务器端 JProfiler 安装:
把 jprofiler_linux_5.1.2.sh 上传到到服务器,假设路径为 /opt
# cd /opt
# chmod +x *.sh
# ./jprofiler_linux_5.1.2.sh -c
按照提示来安装,提示都很简单,不在多说。安装路径选择 /opt/jprofiler5
注意,这里的 -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/jprofiler5 ;next
6). 选择服务器的 JDK 环境,这里是:Sun,1.6.0,hotspot;next
7). 输入端口:这里是默认值 8849;next
8). 选择启动模式:这里选第一种 wait for a connection from the jprofiler GUI;next
9). 这里会列出需要在服务器端做的配置(这些信息很重要,能否配置成功均在于此):
Integration type: [Generic application]
Selected JVM: Sun 1.6.0 (hotspot)
Startup mode: Wait for JProfiler GUI
(1) Please insert
-agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler5/bin/agent.jar
into the start command of your remote application right after the java command.
(2) Please add
/opt/jprofiler5/bin/linux-x86
to the environment variable LD_LIBRARY_PATH.
A remote session named Remote application on 192.168.1.210 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 ,增加
JPROFILER_HOME=/opt/jprofiler5/bin/linux-x86
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JPROFILER_HOME
(2)修改TOMCAT启动文件catalina.sh,添加-agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler5/bin/agent.jar 内容到CATALINA_OPTS中;
“-agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler4/bin/agent.jar ” 此内容由客户端软件生成
CATALINA_OPTS="$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:
JProfiler> Protocol version 23
JProfiler> Using JVMTI
JProfiler> 32-bit library
JProfiler> Listening on port: 8849.
JProfiler> Native library initialized
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:
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.
注意:
在监测时,会发现连接一段时间后,就会失去连接。这时应修改Tomcat的配置文件server.xml,该文件位于/tomcat/conf目录下。找到后将Shutdown端口号和Connector端口号分别改成8005和8080,就没问题了。
分享到:
相关推荐
性能监控JConsole远程监控Tomcat服务
使用jconsole远程监控tomcat jmx 实验操作详细信息,本人实验实操
现记录下 jprofiler 远程监控tomcat的安装,与起步.
监控tomcat内存使用情况
JProfiler在Windows可视化远程监控Linux上Tomcat进程的安装步骤
loadrunner监控tomcat、监控 tomcat、监控web服务器, 利用loadrunner脚本监控tomcat。
jvisualvm 远程访问 Linux ...使用 jvisualvm 远程访问 Linux 环境中的 Tomcat 需要安装和配置 jdk 和 Tomcat,然后使用 jvisualvm 的 JMX 方法或 jstatd 方法进行监控,最后添加 Visual GC 插件以获取更多的监控信息。
zabbix监控tomcat的监控模板
JVisualVM远程监控linux服务器 tomcatJVisualVM远程监控linux服务器 tomcatJVisualVM远程监控linux服务器 tomcat
云服务上的tomcat监控使用到的jar包,需要的可以直接下载,注意tomcat的版本需要和jar包的版本对应
MyEclipse MyEclipse远程调试tomcat
Eclipse 远程调试Tomcat的应用
监控tomcat资源信息的方法和步骤,供大家参考
Windows平台下监控Tomcat运行时服务假死或异常后并尝试自动重启Tomcat,已测试可用 Windows平台下监控Tomcat运行时服务假死或异常后并尝试自动重启Tomcat,已测试可用
JConsole是一个基于JMX的GUI工具,用于连接正在运行的JVM,不过此JVM需要使用可管理的模式启动。如果要把一个应用以可管理的形式启动,可以在启动是设置com.sun.management.jmxremote。JConsole能够提供被监控虚拟机...
zabbix3.4.4监控tomcat实例,需将此类放在tomcat的lib下
Linux定时脚本监控tomcat是否假死或出现运行异常,若出现异常则自动重启。
tomcat安装及配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程Tomcat安装和配置教程...
本文档主要介绍了jmx连接T远程监控tomcat的详细配置,文档包含了一些配置的详细图片和需要注意的内容
利用zabbix JMX 自带模板应用服务监控 tomcat,帮助初学的朋友,是他们能很快上手