java二进制工具
可以运用jdk工具监控java应用性能,再配合 jmeter 进行了一个长时间的加压,在加压过程中重点关注了系统资源的使用情况
D:\Program Files (x86)\Java\jdk1.8.0_111\bin
这个目录下的工具
jps - Lists the instrumented Java Virtual Machines (JVMs) on the target system
jarsigner - Signs and verifies Java Archive (JAR) files.
=================================
jconsole
本地进程
远程进程
=================================
java mission control
jmc
=================================
jvisualVM
本地
远程
jstatd连接
jmx连接
两种地址
1、ip:port
2、jmx service url (service:jmx:rmi:///jndi/rmi://192.168.3.15:9999/jmxrmi)
service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi
service:jmx:rmi:///jndi/rmi://<hostname>/jmxrmi
另外我们还可以为VisualVM安装一些插件,比如GC,MBeans等等。满足自己的需要。
=================================
jstatd
jstatd是一个rmi的server应用,用于监控jvm的创建和结束,并且提供接口让监控工具可以远程连接到本机的jvm 。jstatd位于 $JAVA_HOME/bin目录下
jstatd是一个监控 JVM 从创建到销毁过程中资源占用情况并提供远程监控接口的 RMI ( Remote Method Invocation ,远程方法调用)服务器程序,它是一个 Daemon 程序,要保证远程监控软件连接到本地的话需要 jstatd 始终保持运行。
jmx
JMX:Java Management Extensions ,即 Java 管理扩展 , 是一个为应用程序、设备、系统等植入管理功能的框架。 JMX 可以跨越一系列异构操作系统平台、系统体系结构和网络传输协议,灵活的开发无缝集成的系统、网络和服务管理应用 。而Visual VM是通过 JMX 来和远程 Java 应用联系的
=================================
在需要被监控的服务器上面,通过jstatd来启动RMI服务
新建文件,编辑内容,启动守护,再visualVM添加jstatd连接
[root@localhost bin]# pwd
/root/jdk1.8.0_144/bin
jstatd运行需要通过 -J-Djava.security.policy=*** 指定安全策略,因此我们需要在服务器上建立一个指定安全策略的文件jstatd.all.policy ,文件内容如下:
[root@localhost bin]# cat jstatd.all.policy
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
上面内容格式不正确,可能导致不能正常连接
看man jstatd,里面都有解释
-Joption
Passes option to the JVM, where option is one of the options described on the reference page for the Java application launcher. For example, -J-
Xms48m sets the startup memory to MB. See java().
[root@localhost bin]# ./jstatd -J-Djava.security.policy=jstatd.all.policy
默认就是1099
jstatd -J-Djava.security.policy=/root/jstatd.policy -p 2099
要使Java VisualVM 成功连接到远程服务器上,服务器端应该在 /etc/hosts 文件中把本机地址设为本机的 IP 地址。使用 hostname -i 命令查看,如果显示的是 127.0.0.1 或者与本机实际 IP 不一致的话,需要把 /etc/hosts 文件中相应的地址改为本机实际 IP 。
[root@localhost ~]# jstatd -J-Djava.security.policy=/root/jdk1.8.0_144/bin/jstatd.all.policy -J-Djava.rmi.server.logCalls=true
Jun 17, 2019 2:43:02 PM sun.rmi.server.UnicastServerRef logCall
FINER: RMI TCP Connection(1)-127.0.0.1: [127.0.0.1: sun.rmi.registry.RegistryImpl[0:0:0, 0]: void rebind(java.lang.String, java.rmi.Remote)]
Jun 17, 2019 2:43:02 PM sun.rmi.server.UnicastServerRef logCall
FINER: RMI TCP Connection(2)-127.0.0.1: [127.0.0.1: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]
Jun 17, 2019 2:43:02 PM sun.rmi.server.UnicastServerRef logCall
FINER: RMI TCP Connection(3)-192.168.3.169: [192.168.3.169: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
Jun 17, 2019 2:43:07 PM sun.rmi.server.UnicastServerRef logCall
FINER: RMI TCP Connection(3)-192.168.3.169: [192.168.3.169: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
Jun 17, 2019 2:43:11 PM sun.rmi.server.UnicastServerRef logCall
上面是没有改hosts文件时的console输出
下面是改后的console输出
FINER: RMI TCP Connection(4)-192.168.3.169: [192.168.3.169: sun.tools.jstatd.RemoteVmImpl[-6199bad7:16b6432834d:-7ff8, 7381047654591843568]: public abstract byte[] sun.jvmstat.monitor.remote.RemoteVm.getBytes() throws java.rmi.RemoteException]
Jun 17, 2019 2:51:01 PM sun.rmi.server.UnicastServerRef logCall
FINER: RMI TCP Connection(4)-192.168.3.169: [192.168.3.169: sun.tools.jstatd.RemoteVmImpl[-6199bad7:16b6432834d:-7ff2, 5427747741497180388]: public abstract byte[] sun.jvmstat.monitor.remote.RemoteVm.getBytes() throws java.rmi.RemoteException]
Jun 17, 2019 2:51:01 PM sun.rmi.server.UnicastServerRef logCall
FINER: RMI TCP Connection(4)-192.168.3.169: [192.168.3.169: sun.tools.jstatd.RemoteHostImpl[-6199bad7:16b6432834d:-7fff, 8336527158749228898]: public abstract int[] sun.jvmstat.monitor.remote.RemoteHost.activeVms() throws java.rmi.RemoteException,sun.jvmstat.monitor.MonitorException]
Jun 17, 2019 2:51:01 PM sun.rmi.server.UnicastServerRef logCall
=================================
jps
pid java应用主类名称
[root@test1 ~]# jps
5729 Bootstrap
5782 Jstatd
PID: 5782
Host: 192.168.3.15
Main class: sun.tools.jstatd.Jstatd
PID: 5729
Host: 192.168.3.15
Main class: org.apache.catalina.startup.Bootstrap
[root@test1 bin]# jps
Bootstrap
Jps
[root@test1 bin]# jps -q [root@test1 bin]# jps -l
org.apache.catalina.startup.Bootstrap
sun.tools.jps.Jps
[root@test1 bin]# jps -m
Bootstrap start
Jps -m
[root@test1 bin]# jps -lm
org.apache.catalina.startup.Bootstrap start
sun.tools.jps.Jps -lm
[root@test1 bin]# jps -v
Bootstrap -Djava.util.logging.config.file=/root/apache-tomcat-8.5./conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize= -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.3.15 -Dcom.sun.management.jmxremote.port= -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcatalina.base=/root/apache-tomcat-8.5. -Dcatalina.home=/root/apache-tomcat-8.5. -Djava.io.tmpdir=/root/apache-tomcat-8.5./temp
Jps -Dapplication.home=/root/jdk1..0_144 -Xms8m
[root@test1 bin]# jps -lvm
org.apache.catalina.startup.Bootstrap start -Djava.util.logging.config.file=/root/apache-tomcat-8.5./conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize= -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.3.15 -Dcom.sun.management.jmxremote.port= -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcatalina.base=/root/apache-tomcat-8.5. -Dcatalina.home=/root/apache-tomcat-8.5. -Djava.io.tmpdir=/root/apache-tomcat-8.5./temp
sun.tools.jps.Jps -lvm -Dapplication.home=/root/jdk1..0_144 -Xms8m
=================================
为tomcat 配置 jvm 启动参数,以便监控
CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=192.168.3.225
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"
==================================
[root@test1 bin]# jps
Bootstrap
Jps
得到pid jstat - Monitors Java Virtual Machine (JVM) statistics. [root@test1 bin]# jstat -help
Usage: jstat -help|-options
jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]] Definitions:
<option> An option reported by the -options option
<vmid> Virtual Machine Identifier. A vmid takes the following form:
<lvmid>[@<hostname>[:<port>]]
Where <lvmid> is the local vm identifier for the target
Java virtual machine, typically a process id; <hostname> is
the name of the host running the target Java virtual machine;
and <port> is the port number for the rmiregistry on the
target host. See the jvmstat documentation for a more complete
description of the Virtual Machine Identifier.
<lines> Number of samples between header lines.
<interval> Sampling interval. The following forms are allowed:
<n>["ms"|"s"]
Where <n> is an integer and the suffix specifies the units as
milliseconds("ms") or seconds("s"). The default units are "ms".
<count> Number of samples to take before terminating.
-J<flag> Pass <flag> directly to the runtime system. [root@test1 bin]# jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation
得到options [root@test1 bin]# jstat -compiler
Compiled Failed Invalid Time FailedType FailedMethod
9.06
[root@test1 bin]# jstat -gc
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
18432.0 20480.0 480.0 0.0 103936.0 12717.6 142336.0 11663.3 20736.0 19683.0 2560.0 2207.3 0.178 0.033 0.211
[root@test1 bin]# jstat -gcutil
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
2.60 0.00 12.27 8.19 94.92 86.22 0.178 0.033 0.211 ============================================
jstack - Prints Java thread stack traces for a Java process, core file, or remote debug server. [root@test1 bin]# jstack
Usage:
jstack [-l] <pid>
(to connect to running process)
jstack -F [-m] [-l] <pid>
(to connect to a hung process)
jstack [-m] [-l] <executable> <core>
(to connect to a core file)
jstack [-m] [-l] [server_id@]<remote server IP or hostname>
(to connect to a remote debug server) Options:
-F to force a thread dump. Use when jstack <pid> does not respond (process is hung)
-m to print both java and native frames (mixed mode)
-l long listing. Prints additional information about locks
-h or -help to print this help message [root@test1 bin]# jstack -l
-- ::
Full thread dump Java HotSpot(TM) -Bit Server VM (25.144-b01 mixed mode): "Attach Listener" # daemon prio= os_prio= tid=0x00007f5f3c013800 nid=0x1928 waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE Locked ownable synchronizers:
- None
java二进制工具的更多相关文章
- java开发工具比较(16个工具修订版)
1.JDK (Java Development Kit)Java开发工具集 SUN的Java不仅提了一个丰富的语言和运行环境,而且还提了一个免费的Java开发工具集(JDK).开发人员和最终用户可以利 ...
- 十四种Java开发工具点评
在计算机开发语言的历史中,从来没有哪种语言象Java那样受到如此众多厂商的支持,有如此多的开发工具,Java菜鸟们如初入大观园的刘姥姥,看花了眼,不知该何种选择.的确,这些工具各有所长,都没有绝对完美 ...
- Java开发工具全面比较
1.JDK (Java Development Kit)Java开发工具集 从初学者角度来看Java开发工具,采用JDK开发Java程序能够很快理解程序中各部分代码之间的关系,有利于理解Java面向对 ...
- Java效率工具Lombok使用与原理
Java效率工具Lombok使用与原理 我个人觉得 Lombok是一个优化Java代码以及提升开发效率不错的工具.Lombok 的Github地址为:https://github.com/rzwits ...
- 【转】高效Java编程工具集锦
原文地址:http://geek.csdn.net/news/detail/57469 Java 开发者常常都会想办法如何更快地编写 Java 代码,让编程变得更加轻松.目前,市面上涌现出越来越多的高 ...
- Java开发工具安装步骤内容如下
Java开发工具安装步骤内容如下 安装 开发工具 STS 链接下载网址 eclipse 链接下载网址 JDK安装 jdk链接下载地址 Marven环境 marven链接下载地址 Tomcat tomc ...
- Java 二进制与十六进制转换
Java 二进制与十六进制转换 二进制转换十六进制 /** * @description 将二进制转换成16进制 * * @param buf * @return */ public static S ...
- JAVA开发工具eclipse中@author怎么改
1:JAVA开发工具eclipse中@author怎么改,开发的时候为了注明版权信息. 用eclipse开发工具默认的是系统用户,那么怎么修改呢 示例如图所示 首先打开Eclipse--->然后 ...
- Java Properties工具类详解
1.Java Properties工具类位于java.util.Properties,该工具类的使用极其简单方便.首先该类是继承自 Hashtable<Object,Object> 这就奠 ...
随机推荐
- Delphi 使用Tabel组件的记录查找
樊伟胜
- Pythonic定义
Pythonic定义 Python最常用的编码风格还是PEP8,详见:http://jython.cn/dev/peps/pep-0008/ Pythonic确实很难定义,先简单引用下<Pyth ...
- GMT、UTC、UNIX时间戳、时区
GMT.UTC.CTS: UTC时间:世界协调时间(UTC)是世界上不同国家用来调节时钟和时间的主要时间标准,也就是零时区的时间.UTC是以原子时秒长为基础,在时刻上尽量接近于GMT的一种时间计量系统 ...
- string类的总结
一.string类头文件:#include <string>;using namespace std; 二.string类方法: 1.获取string的字符串长度:size(),size返 ...
- python自动生成excel(xlwt库)
下面代码使用web.py框架,其他框架都大同小异. # coding: utf- import web import json import datetime import xlwt import S ...
- RHEL6使用系统自带多路径软件配置多路径
1.多路径的主要功能 多路径一般配合存储设备实现如下功能: 故障的切换和恢复 IO流量的负载均衡 磁盘的虚拟化 2.查看系统自带的多路径软件是否安装 [root@cluster01 ~]# ...
- xenserver 下载模板
cd /tmp rm -rf Auto.sh wget http://os.xensystem.net/XenSystem/download/Customer/Auto.sh sh Auto.sh
- QTP(11)
练习:录制Flight登录-打开1-10之间随机编号的订单-退出,打开完订单后,退出前,使用msgbox输出“顾客x预定了y从z到w的c类型的k张票!”说明:x是顾客姓名.y是日期.z是FlyFrom ...
- php的加解密openssl_encrypt与openssl_decrypt
https://blog.csdn.net/zhemejinnameyuanxc/article/details/83383434 php的加解密
- hdf5文件、tqdm模块、nunique、read_csv、sort_values、astype、fillna
pandas.DataFrame.to_hdf(self, path_or_buf, key, **kwargs): Hierarchical Data Format (HDF) ,to add an ...