Use jvisualvm remote monitoring tomcat (Ali cloud ECS)

 

EDITORIAL: Use jvisualvm remote monitoring tomcat (Ali cloud ECS), the connection is being given: service: jmx: rmi: //// jndi / rmi: IP: port // connect to the IP: port, the Internet to find a lot of information, failed to solve, it has now been resolved, the next record, for reference

This article surveillance Ali cloud ecs tomcat server practice for the local remote jvisualvm

Ready to work:

1. jdk installed on the server, the execution environment linux command java -version, shown below indicates successful installation of FIG.

 

2.tomcat, and start tomcat and can be accessed locally normal, as shown below:

 3. Modify the tomcat catalina.sh file to start Jmx service configuration, operation command as follows:

    cd /bin

   we catalina.sh

   Type capital G, skip to the last line of the document

  Input / JAVA_OPTS = After pressing Enter, the following diagram add the following location (location to be right, otherwise tomcat can not start up the port):

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=端口 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.net.preferIPv4Stack=true -Djava.rmi.server.hostname=服务器IP"       

  Note: The above modified to add content to remember its own port and server IP, and authenticate = false, there is no need to configure authorization

  Then, press Esc to exit, press: wq to save

 Adding configure the final results as shown below:

 Finally, restart tomcat, after a successful start -nltp enter netstat to see whether the port started successfully, in addition jmx Server will start the other two random interface at the same time, as shown below:

 

阿里云安全组设置,登录阿里云,进入控制台->ECS服务器 ->网络与安全->安全组,在实例列表中点击更多,点击配置规则

 

 

 点击快速创建规则,将上面的3个端口分别加入规则中,加入内容填写如下:

 

 

 

 

        

 

进入本地jdk安装目录bin目录(前提是本地要安装了JDK,如未安装请先安装),找到jvisualvm并打开

 

 

 

上图中点击确定即可添加成功,连接成功后会在主机下会有对应的连接显示,如下图

 

 

常见问题:

1.无法使用 service:jmx:rmi:////jndi/rmi:IP:端口//  连接到 IP:端口

解决办法:将随机端口添加到安全组(不需要像其它资料上说的要将防火墙firewall改成iptable)

2.在catalina.sh中添加配置后没有启动jmx端口

解决办法:配置内容不要放在catalina.sh文档的最后,一定要放在正确的位置,如上图

 3.如tomcat无法访问,可以使用service firewalld status查看状态,如下是关闭状态:

关闭防火墙命令: 

开启防火墙命令:

 

Guess you like

Origin www.cnblogs.com/wx170119/p/11237315.html