一、tomcat开启jmx
启动脚本中添加
CATALINA_OPTS="-Djava.rmi.server.hostname=本机IP
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=端口
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
"
添加后重启tomcat
因为开启jmx后会随机开启其它随机端口号 如需从其它机器远程调试 需将tomcat所在服务器的防火墙关掉。
二、下载jmxterm
地址 http://sourceforge.net/projects/cyclops-group/files/jmxterm/
运行jmxterm
java -jar jmxterm-1.0-alpha-4-uber.jar
打开后效果如下
java -jar jmxterm-1.0-alpha-4-uber.jar
Welcome to JMX terminal. Type "help" for available commands.
$>
三、使用jmxterm
1,创建连接
$>open localhost:45219
#Connection to localhost:45219 is opened
2,查看支持哪些domain
$>domains
#following domains are available
Catalina
Catalina7080
JMImplementation
Users
com.sun.management
java.lang
java.util.logging
3,查看支持哪些beans
$>beans
java.lang:name=PS Eden Space,type=MemoryPool
java.lang:name=PS MarkSweep,type=GarbageCollector
java.lang:name=PS Old Gen,type=MemoryPool
java.lang:name=PS Perm Gen,type=MemoryPool
java.lang:name=PS Scavenge,type=GarbageCollector
java.lang:name=PS Survivor Space,type=MemoryPool
java.lang:type=ClassLoading
java.lang:type=Compilation
java.lang:type=Memory
java.lang:type=OperatingSystem
java.lang:type=Runtime
java.lang:type=Threading
#domain = java.util.logging:
java.util.logging:type=Logging
(此处省略)
jmxterm 支持tab 自动补全
例子:
查看tomcat版本(使用了自动tab 自动补全)
$>domain
domain domains
$>domain Catalina
Catalina Catalina7080
$>domain Catalina
#domain is set to Catalina
$>bean type=S
type=Server type=StringCache
$>bean type=Server
#bean is set to Catalina:type=Server
$>get serv
serverInfo serviceNames
$>get serverInfo
#mbean = Catalina:type=Server:
serverInfo = Apache Tomcat/6.0.24;
更多信息请自行查看并了解。
来源:oschina
链接:https://my.oschina.net/u/1436224/blog/384768