Tomcat监控管理
Tomcat监控管理
===================
方法一:开发Java监控页面
<%
Runtime rtm = Runtime.getRuntime();
long mm = rtm.maxMemory()/1024/1024;
long tm = rtm.totalMemory()/1024/1024;
long fm = rtm.freeMemory()/1024/1024;
out.println("Max memory:"+mm+"MB"+"<br>");
out.println("Total memory:"+tm+"MB"+"<br>");
out.println("Free memory:"+fm+"MB"+"<br>");
out.println("Available memory can be used is :"+(mm+fm-tm)+"MB"+"<br>");
%>
保存退出
·······································································
方法二:使用jsp命令进行监控
上传安装jdk才能使用jsp -lvm命令 ( jdk-8u191-linux-x64.tar.gz)
[root@localhost ~]# rm -rf /usr/bin/java
[root@localhost ~]# tar xf jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# mv jdk1.8.0_191/ /usr/local/java
[root@localhost ~]# vim /etc/profile
[root@localhost ~]# sed -i '$aexport JAVA_HOME=/usr/local/java\nexport PATH=$PATH:$JAVA_HOME/bin' /etc/profile
[root@localhost ~]# source /etc/profile
[root@localhost ~]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
[root@localhost ~]# jps -lvm
2021 org.apache.catalina.startup.Bootstrap start -Djava.util.logging.config.file=/usr/local/tomcat8/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -Dcatalina.base=/usr/local/tomcat8 -Dcatalina.home=/usr/local/tomcat8 -Djava.io.tmpdir=/usr/local/tomcat8/temp
2764 sun.tools.jps.Jps -lvm -Dapplication.home=/usr/local/java -Xms8m
···········································································
方法三:开启tomcat远程监控功能 (很重要)
修改配置文件,开启远程监控
[root@localhost ~]# vim /usr/local/tomcat8/bin/catalina.sh
2 CATALINA_OPTS="$CATALINA_OPTS
3 -Dcom.sun.management.jmxremote
4 -Dcom.sun.management.jmxremote.port=12345 #端口号12345
5 -Dcom.sun.management.jmxremote.authenticate=false //验证时关闭的
6 -Dcom.sun.management.jmxremote.ssl=flase #
7 -Djava.rmi.server.hostname=192.168.200.67"
保存退出
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh
[root@localhost ~]# netstat -lnpt //关注12345端口
tcp6 0 0 :::12345 :::* LISTEN 4161/java
tcp6 0 0 :::8080 :::* LISTEN 4161/java
在Windows中安装jdk 点击/bin/jconsole.exe 用于查看监控信息CPU使用,栈内存使用等
jconsole.exe这个是一个监控软件
注意windows需要安装jdk环境!
下载地址:http://www.oracle.com/techneteork/java/javase/downloads/index.html
以deb结尾的jdk安装包是ubuntu系统的
tomcat下载地址:tomcat.apache.org 选择core表示源码
mysql下载地址:mysql.com/downloads/
命令:md5sum 安装包 用来检测安装包的序列号,看与官网是否一致,说明没有被中间人篡改过。
完~~~
~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!