JProfiler安装
环境
- Centos Linux 7.4
- tomcat 8.0、jdk1.8.0_181
- jprofiler_linux_10_1_3.tar.gz
- jprofiler_windows-x64_10_1_3
下载软件
官网地址:http://www.ej-technologies.com/download/jprofiler/files ,一个linux服务端,一个windows客户端 GUI界面
linux版本要和windows版保持一致
Linux服务器安装
1、下载好后把tar包上传的linux服务器,解压。
安装目录 /usr/local/jprofiler/
tar -zvxf jprofiler_linux_10_1_3.tar.gz
2,修改tomcat配置
进入tomcat的bin目录,修改startup.sh文件,在文件开始增加如下配置:
JAVA_OPTS='-Xms256m -Xmx1024mm'
CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS -agentpath:/usr/local/jprofiler/jprofiler10.1.3/bin/linux-x64/libjprofilerti.so=port=8849,nowait"
export CATALINA_OPTS
- 修改后的startup.sh文件,完整如下
#!/bin/sh # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ----------------------------------------------------------------------------- # Start Script for the CATALINA Server # ----------------------------------------------------------------------------- JAVA_OPTS='-Xms256m -Xmx1024mm' CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS -agentpath:/usr/local/jprofiler/jprofiler10.1.3/bin/linux-x64/libjprofilerti.so=port=8849,nowait" export CATALINA_OPTS # Better OS/400 detection: see Bugzilla 31132 os400=false case "`uname`" in OS400*) os400=true;; esac # resolve links - $0 may be a softlink PRG="$0" while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists if $os400; then # -x will Only work on the os400 if the files are: # 1. owned by the user # 2. owned by the PRIMARY group of the user # this will not work if the user belongs in secondary groups eval else if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 fi fi exec "$PRGDIR"/"$EXECUTABLE" start "$@"
3、再重启tomcat
可以看到8849端口启动成功了。
Windows客户端安装
jprofiler_windows-x64_10_1_3.exe,直接安装,选择自定义安装位置即可
连接linux监控Tomcat运行状态
1. New Remote Integration
打开jprofiler程序,在Session菜单中打开“Integration Wizards”,选择“New Remote Integration”,打开配置对话框。
2. 选择部署的容器
在面板中显示出了所有支持可以监视的多种服务器类型,包括Tomcat、Resin等。
因为我们使用Tomcat8.0部署web应用,所以我们选择Apache Tomcat 8.x,并点击下一步。
3. 选择JDK版本
4. 选择启动监控的方式
对连接的时机控制有以下三种:
等待模式 wait for a connection from the Jprofiler GUI
- 此模式为在启动容器Weblogic/Tomcat时,需要等Jprofiler连接后才能启动,JVM TI是采用事件通知方式告知JProfiler相关的Jvm的状态变化,等待模式可以不漏掉通知。
非等待模式 Start Immeditely
- 此模式下容器Weblogic/Tomcat独立启动,Jprofiler随时可以连接。
离线模式 Profile offline, Jprofiler GUI cannot connect
- 此模式为离线模式,生成相关记录文件事后分析。
5. 设置远程Linux服务器地址
6. 设置linux中jprofiler安装路径
7. 选择容器启动脚本
- Tomat容器的启动可以由jprofiler来控制,jprofiler要修改启动文件加入JVM TI参数实现监视目的。
- 选择好Tomat启动脚本后,jprofiler会自动为我们生成新的启动脚本,文件名是startup_jprofiler.sh,通过这个文件来启动Tomcat。
- 启动脚本,必须来自远程服务器中的startup.sh。这个启动脚本,必须能够访问,所以需要从远程服务器拷贝到本地一份,或者在远程服务器挂载一个可写的驱动。
- 这里,我拷贝到 D:\Java\jprofiler\back\test\CloudPayment
- 选择好Tomat启动脚本后,jprofiler会自动为我们生成新的启动脚本,文件名是startup_jprofiler.sh
- startup_jprofiler.sh内容
#!/bin/sh # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ----------------------------------------------------------------------------- # Start Script for the CATALINA Server # ----------------------------------------------------------------------------- JAVA_OPTS='-Xms256m -Xmx1024mm' CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS -agentpath:/usr/local/jprofiler/jprofiler10.1.3/bin/linux-x64/libjprofilerti.so=port=8849,nowait" export CATALINA_OPTS # Better OS/400 detection: see Bugzilla 31132 os400=false case "`uname`" in OS400*) os400=true;; esac # resolve links - $0 may be a softlink PRG="$0" while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` EXECUTABLE=catalina.sh # Check that target executable exists if $os400; then # -x will Only work on the os400 if the files are: # 1. owned by the user # 2. owned by the PRIMARY group of the user # this will not work if the user belongs in secondary groups eval else if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then echo "Cannot find $PRGDIR/$EXECUTABLE" echo "The file is absent or does not have execute permission" echo "This file is needed to run this program" exit 1 fi fi # The following lines have been added by the # application server integration wizard of JProfiler CATALINA_OPTS="-agentpath:/usr/local/jprofiler/jprofiler10.1.3/bin/linux-x64/libjprofilerti.so=port=8849 $CATALINA_OPTS" export CATALINA_OPTS # end of modifications exec "$PRGDIR"/"$EXECUTABLE" run "$@"
8. 选择启动端口
和startup.sh中添加的内容,保持一致
9. 查看配置汇总信息
信息的内容说
创建了一个启动脚本startup_jprofiler.sh,在相同的目录里。可以用它的来启动。
其中添加了CATALINA_OPTS参数,别被你人为的覆盖了。
10. 创建完成
11. 客户端效果