JConsole监控远程linux下的JVM

环境:
服务器端: Linux + jdk1.7.0_75 + tomcat 7
本地: Win + jdk1.7.0_55

一、修改/etc/hosts文件

hostname -i 如果显示127.0.0.1时,修改/etc/hosts 将127.0.0.1替换成linux服务器的真实ip

了解更多测试知识访问如下链接:

https://edu.csdn.net/course/detail/22948

https://edu.csdn.net/lecturer/3215

https://edu.csdn.net/course/detail/30898

https://edu.csdn.net/course/detail/25768

 

二、修改 catalina.sh文件

vim  /usr/local/tomcat7**/bin/catalina.sh   #进入tomcat的bin目录下

在# OS specific support.  $var _must_ be set to either true or false.下增加

#JAVA_OPTS="-Dcom.sun.management.jmxremote.port=9008 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

 

三、修改jmxremote.access和jmxremote.password.template

cd /usr/java/jdk1.7.0_75/jre/lib/management

vim jmxremote.access

monitotRole 只读权限  随意添加一个用户xxxx    controlRole 读写权限,添加用户admin

#monitorRole   readonly

lisssss   readonly

#controlRole   readwrite \

admin   readwrite \

              create javax.management.monitor.*,javax.management.timer.* \

              unregister

mv jmxremote.password.template   jmxremote.password #重命名

chmod +w  jmxremote.password  #增加写权限

vim jmxremote.password   为只读用户和读写用户设置密码

# monitorRole  QED

lisssss 1234xx

# controlRole   R&D

admin 1234xx

四、打开本地jconsole,连接远程linux中jvm

     1.打开jconsole

         cmd----jconsole 或者双击C:\Program Files\Java\jdk1.7.0_55\bin下的jconsole.exe

     2.连接远程linux中jvm

       选择远程进程:远程服务器的ip:端口号  用户名、口令输入jmxremote.password中的用户名或密码---点击连接

 

JConsole监控远程linux下的JVM_第1张图片

 jconsole监控成功如下图:

JConsole监控远程linux下的JVM_第2张图片

 

问题:监控后,关闭tomcat,报错:提示9008端口号被占用,原因在关闭tomcat时,也执行了Catalish中的jmxremote的端口号

[root@localhost bin]# ./shutdown.sh

/usr/local/tomcat7-java_shop/bin/catalina.sh: line 101: -agentpath:/opt/jprofiler7/bin/linux-x64/libjprofilerti.so=port=8080: No such file or directory

Using CATALINA_BASE:   /usr/local/tomcat7**

Using CATALINA_HOME:   /usr/local/tomcat7**

Using CATALINA_TMPDIR: /usr/local/tomcat7**/temp

Using JRE_HOME:        /usr/java/jdk1.7.0_75

Using CLASSPATH:       /usr/local/tomcat7-java_shop/bin/bootstrap.jar:/usr/local/tomcat7**/bin/tomcat-juli.jar

Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 9008; nested exception is:

    java.net.BindException: Address already in use

JAVA_OPTS="$JAVA_OPTS -Xms256m -Xmx1024m -XX:PermSize=128M -XX:MaxPermSize=256m"if [ "$1" = "start" ];then

     echo "set console";

     JAVA_OPTS="-Dcom.sun.management.jmxremote.port=9008 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false";else

  echo "no startup";fi;

了解更多测试知识访问如下链接:

https://edu.csdn.net/course/detail/22948

https://edu.csdn.net/lecturer/3215

https://edu.csdn.net/course/detail/30898

https://edu.csdn.net/course/detail/25768

 

 

你可能感兴趣的:(JConsole监控远程JVM,JVM,JConsole,服务器监控,JVM,JConsole)