jprofiler远程监控JVM(springboot项目)
2019-08-01 本文已影响0人
LittleJessy
jprofiler 安装
-
Linux服务器安装
官网地址,选择:
在这里插入图片描述
下载后上传到被测服务器的/opt 下,解压,重命名为:jprofiler11 -
本机安装客户端
mac破解版下载地址
按照网页上的教程下载安装即可。
配置及启动
- 服务器端配置
- 配置/etc/profile文件,添加如下内容
export INSTALL4J_JAVA_HOME=/server/jdk1.8.0_151/jre #jdk安装目录下
export LD_LIBRARY_PATH=/opt/jprofiler11/bin/linux-x86 #jprofile的安装目录下
然后source一下,使立即生效:
# source /etc/profile
- 进入/opt/jprofiler11/bin目录,执行:
# sudo -u tomcat /opt/jprofiler11/bin/jpenable
如果出现如下报错:
No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be at least 1.6 and at most 11.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
需要修改jpenable文件,执行:vim jpenable 编辑文件,修改后如下:
# Uncomment the following line to override the JVM search sequence
INSTALL4J_JAVA_HOME_OVERRIDE=/server/jdk1.8.0_151/
# Uncomment the following line to add additional VM parameters
# INSTALL4J_ADD_VM_PARAMS=
再次执行,成功。先选择mode:1,然后输入连接端口号:8849:
# sudo -u tomcat /opt/jprofiler11/bin/jpenable
Connecting to /server/application/xw-web/ef9c48.../jprofiler11/bin/agent.jar [20480] ...
Please select the profiling mode:
GUI mode (attach with JProfiler GUI) [1, Enter]
Offline mode (use config file to set profiling settings) [2]
1
Please enter a profiling port
[35634]
8849
You can now use the JProfiler GUI to connect on port 8849
- 服务启动时需要添加jprofile的配置:-agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler11/bin/agent.jar
//先查询出项目启动进程并杀死
# ps -ef | grep /server/application/xw-web |grep -v grep|grep tomcat|awk '{print $2}'
19205
# kill -s 9 19205
//进入项目包存放目录,执行启动命令
# su - tomcat -c 'nohup java -Dserver.port=8080 -server -Xms256M -Xmx512M -Xmn128M -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256M -Xss512k -XX:+DisableExplicitGC -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=10 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M-XX:+UseFastAccessorMethods -XX:CMSInitiatingOccupancyFraction=70 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/server/application/xw-web/logs/ -Djava.io.tmpdir=/server/application/xw-web/temp -Dspring.profiles.active=perf -jar /server/application/xw-web/ef9c483.jar>>/server/application/xw-web/logs/catalina.out -agentlib:jprofilerti=port=8849 -Xbootclasspath/a:/opt/jprofiler11/bin/agent.jar 2>&1 &'
-
客户端配置
具体操作如下图:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
image.png
在这里插入图片描述
配置完成后,即可看到服务器上的监控数据:
在这里插入图片描述