Linux:远程服务器Tomcat监控,使用jconsole远程连接centos7 服务器上的tomcat来查看服务器状况(无密码版)

说明:在此我使用的是Xshell6连接的服务器进行操作。
参考链接:https://blog.csdn.net/unhejing/article/details/79882618
1、打开Xshell6,弹出会话窗口
2、在会话窗口点击新建,输入名称和主机(ip地址)然后确定
3、选中连接——>接受并保存——>输入登录用户名——>输入密码——>确定。、
(了解查看tomcat版本信息命令:
使用curl命令收集网页信息,过滤出“Apache Tomcat”即可
命令:curl Tomcat_ip_addr:port | grep “Apache Tomcat”
优点:最常用的方法,不需要进入后台即可查看,简单可行。
风险:有些公司会隐藏版本信息或tomcat的名称,有一定误导性。)

4、首先ps -ef|grep tomcat 查看一下tomcat进程的信息
在这里插入图片描述
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=xxxx

5、如果未启动tomcat查看不了,请启动后再查看,启动命令:
在这里插入图片描述
6、最好先把catalina.sh文件备份一下再用vim打开你服务器上的catalina.sh文件进行编辑

在文件中最前面添加

JAVA_OPTS="-Dcom.sun.management.jmxremote.port=6969
-Dcom.sun.management.jmxremote.rmi.port=6969
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=106.15.188.221"
截图如下:
在这里插入图片描述
代码解释:

-Dcom.sun.management.jmxremote.port=6969 //连接端口,自定义不要与已有的端口冲突

-Dcom.sun.management.jmxremote.rmi.port=6969 //这句一定要添加,不添加就无法成功

-Dcom.sun.management.jmxremote.authenticate=false //不需要密码登陆

-Dcom.sun.management.jmxremote.ssl=false //不需要安全证书

-Djava.rmi.server.hostname=106.15.188.221"//这个ip是自己服务器的外网ip
配置完以后重新加载文件,再重启tomcat服务器:
systemctl daemon-reload
./startup.sh
7、使用more /etc/hosts查看是否有127.0.0.1的ip,如果有修改为外网ip
在这里插入图片描述
8、查看端口号是否被监听netstat -antup | grep 6969
在这里插入图片描述
9、防火墙开启端口号命令firewall-cmd --zone=public --add-port=端口号/tcp --permanent
10、重新加载防火墙firewall-cmd --reload
11、如有需要再关闭tomcat重新启动下 关闭命令: # ./shutdown
启动命令 # ./startup.sh

猜你喜欢

转载自blog.csdn.net/ljl940811/article/details/92806244