visualVM远程监控tomcat

    xiaoxiao2021-10-30  98

    jdk自带有个jvisualvm工具、该工具是用来监控Java运行程序的cpu、内存、线程等的使用情况。废话不多说 ,看配置远程监控过程!

    1、 tomcat启动配置,在bin/startup.sh最后 一行前加入配置: export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx  -Dcom.sun.management.jmxremote.port=xxx -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password  -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access"

    简单解释一下参数:

    -Djava.rmi.server.hostname=192.168.186.114主机地址,这里我采用的是我本机的地址

    -Dcom.sun.management.jmxremote.port=8999  端口号、配置完端口号之后需要将此端口开放出来,这里我采用的是8999端口

    -Dcom.sun.management.jmxremote.authenticate=false 是否开启认证、false的时候可以不使用密码访问,这里我选择的是false

    -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access  以上配置是开启认证时使用的access文件和password文件

    2、 tomcat/conf/加入如下两个文件:

    jmxremote.access:

               username1 readonly

    username2 readwrite

    jmxremote.password:

    username1password1

    username2 password2

    并且chmod 600 jmx* 更改文件访问权限

    3、 开发端口

     打开端口号:iptables-A INPUT -ptcp --dport 8999 -j ACCEPT

    4、catalina-jmx-remote.jar jar包放入到tomcat /lib下

    下载地址:http://download.csdn.net/detail/scgaopan/9686470

    5.在tomcat的安装目录下的conf/server.xml加上

    <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"            rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" />  

    6、startup.sh启动tomcat

    7、 配置visualVM

    远程—添加 主机:填入主机IP:192.168.186.114,右键新添加的主机,添加JMX链接,链接端口号为8999,不适用安全凭证,也不要求SSL链接。点击确定

    转载请注明原文地址: https://ju.6miu.com/read-677882.html

    最新回复(0)