JProfiler10.1.3:远程Linux服务器Tomcat的JVM性能监控

简介: JProfiler10.1.3:远程Linux服务器Tomcat的JVM性能监控

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. 客户端效果




目录
相关文章
|
14天前
|
Java 应用服务中间件 Windows
windows服务器重装系统之后,Tomcat服务如何恢复?
windows服务器重装系统之后,Tomcat服务如何恢复?
30 10
|
2月前
|
应用服务中间件 Docker 容器
在服务器中使用Docker安装Tomcat、同时实现目录挂载、并且部署War包到服务器
这篇文章介绍了在Docker中安装Tomcat的过程,包括搜索Tomcat镜像、拉取镜像、目录挂载的准备、创建并挂载容器,以及如何进入容器和进行测试。文中还说明了如何将WAR包部署到Tomcat服务器并访问部署的应用。
在服务器中使用Docker安装Tomcat、同时实现目录挂载、并且部署War包到服务器
|
2月前
|
传感器 缓存 Prometheus
在Linux中,如何进行硬件性能监控?
在Linux中,如何进行硬件性能监控?
|
2月前
|
缓存 Prometheus 监控
在Linux中,如何进行应用性能监控?
在Linux中,如何进行应用性能监控?
|
2月前
|
Prometheus 监控 Ubuntu
在Linux中,如何进行磁盘性能监控?
在Linux中,如何进行磁盘性能监控?
|
2月前
|
运维 Prometheus 监控
在Linux中,如何进行系统性能监控?
在Linux中,如何进行系统性能监控?
|
2月前
|
网络协议 Java 应用服务中间件
Tomcat源码分析 (一)----- 手撕Java Web服务器需要准备哪些工作
本文探讨了后端开发中Web服务器的重要性,特别是Tomcat框架的地位与作用。通过解析Tomcat的内部机制,文章引导读者理解其复杂性,并提出了一种实践方式——手工构建简易Web服务器,以此加深对Web服务器运作原理的认识。文章还详细介绍了HTTP协议的工作流程,包括请求与响应的具体格式,并通过Socket编程在Java中的应用实例,展示了客户端与服务器间的数据交换过程。最后,通过一个简单的Java Web服务器实现案例,说明了如何处理HTTP请求及响应,强调虽然构建基本的Web服务器相对直接,但诸如Tomcat这样的成熟框架提供了更为丰富和必要的功能。
|
2月前
|
存储 监控 Ubuntu
完全交互式!易于使用的 Linux 性能监控工具
完全交互式!易于使用的 Linux 性能监控工具
|
2月前
|
Java 应用服务中间件 Apache
在 Debian 服务器上安装和配置 Apache Tomcat 的方法
在 Debian 服务器上安装和配置 Apache Tomcat 的方法
26 0
|
3月前
|
前端开发 Java 应用服务中间件
Tomcat 与 JVM 中classpath的理解和设置总结
Tomcat 与 JVM 中classpath的理解和设置总结
117 0
下一篇
无影云桌面