修改jmx远程监控wildfly/jboss配置,然后通过jdk自带的visualvm工具来添加主机监控
修改jmx远程监控wildfly/jboss配置,然后通过jdk自带的visualvm工具来添加主机监控
近新搭建了系统环境,进行压力测试的时候没有一个好的图形化监控方法来比较直观、方便、动态、实时的来监控应用服务器内存、GC、CPU、进程和磁盘等信息,功能非常强大,图像也很友好。但是wildfy配置jmx的文章资料很少,我通过参考官网和一些贴吧实践琢磨出了配置jmx的流程:
1】确认监控端口(一般都是8080端口)
standalone:查看standalone.xml中jboss.http.port为8080
domain:查看standalone.xml中jboss.http.port为8080
# netstat -anlp | grep 8080
tcp 0 0 192.168.101.11:8080 0.0.0.0:* LISTEN 21558/java
———————————————————————————————————————————————————————————————————————————————-
2】通过wildfly的module.xml文件中添加jboss远程监控模块,并启用该模块
standalone:
vim /opt/wildfly/modules/system/layers/base/org/wildfly/extension/io/main/module.xml
domain:
vim /opt/jboss/modules/system/layers/base/org/wildfly/extension/io/main/module.xml
添加,并启用:
<module name=”org.jboss.remoting” export=”true”/>
<module name=”org.jboss.remoting-jmx” export=”true”/>
———————————————————————————————————————————————————————————————————————————————-
3】jboss添加用户jbsuser,并添加权限
standalone:
/opt/wildfly/bin/add-user.sh -a -u jbsuser -p jbsuser
/opt/wildfly/bin/jboss-cli.sh –connect –commands=”/core-service=management/access=authorization/role-mapping=Administrator:add”
/opt/wildfly/bin/jboss-cli.sh –connect –commands=”/core-service=management/access=authorization/role-mapping=Administrator/include=jbsuser:add(name=jbsuser,type=USER)”
domain:
/opt/jboss/bin/add-user.sh -a -u jbsuser -p jbsuser
/opt/jboss/bin/jboss-cli.sh –connect –commands=”/core-service=management/access=authorization/role-mapping=Administrator:add”
/opt/jboss/bin/jboss-cli.sh –connect –commands=”/core-service=management/access=authorization/role-mapping=Administrator/include=jbsuser:add(name=jbsuser,type=USER)”
———————————————————————————————————————————————————————————————————————————————-
4】关闭wildfly,通过切换到jbsuser用户(避免误杀),执行pkill -9 java
———————————————————————————————————————————————————————————————————————————————-
5】启动wildfly,现在就配置好jmx的远程配置了
standalone:
/opt/wildfly/bin/start.sh
domain:
/opt/jboss/bin/start.sh
———————————————————————————————————————————————————————————————————————————————-
6】VisualVM客户端连接:
1、添加远程主机
2、右击,需要点击【添加JMX连接】按钮
3、
service:jmx:http-remoting-jmx://192.xx1.6:8080
输入用户:jbsuser
输入密码:jbsuser
7】激动人心的时刻到了,大家可以点击jmx来监控服务器的资源了,看看成果吧
standalone:看standalone.xml,jboss.http.port
domain:看domain.xml 搜索:jboss.http.port