OwlFocus

Jconsole on Jetty

使用jconsole来连接jetty查看其运行状态。

修改jetty的配置start.ini文件

1
2
3
4
5
6
--exec
OPTIONS=Server,jsp,jmx,resources,websocket,ext,plus,annotations #jmx必须有
-Dcom.sun.management.jmxremote.port=8900
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

参数说明

1
2
3
4
5
6
7
8
-Dcom.sun.management.jmxremote.port=8900 表示启动的端口为8900
-Dcom.sun.management.jmxremote 启动jmx远程管理,默认为true
-Dcom.sun.management.jmxremote.ssl=false 禁用ssl登录
-Dcom.sun.management.jmxremote.authenticate=false
禁用认证,无需输入用户名密码即可登录
--exec 此参数必须有,若漏掉此参数,即使配置了以上参数,远程管理端口也不会启动。只有加上此选项,才会使其他参数生效。

设置完成后,需要重启jetty才能生效。

jconsole连接

jconsole通过ip:port的方式就可连接,如果有防火墙的话请放开相关端口。