linux下visualVMware JVM监控配置

1.安装openjdk

centos:yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel

执行以上命令时,提示:
[root@37_201_test opt]# yum install java-1.8.0-openjdk
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.6 (default, Sep 21 2017, 11:22:35) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

原因:
yum就基于python的,升级python后,yum与高版本的python不兼容,导致yum无法使用

解决办法:
vim /usr/bin/yum
把   :#/usr/bin/python
改为:#/usr/bin/python2.6
即可

  

2.

# cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-1.b13.el6_6.x86_64/jre/lib/management/
# cp jmxremote.password.template jmxremote.password
# chmod 644 jmxremote.password
# vi jmxremote.password
monitorRole  QED      
controlRole   R&D

3.jstatd以守护进程启动

# jstatd -J-Djava.rmi.server.hostname=172.28.37.200 &
[1] 8601
# Could not create remote object
access denied ("java.util.PropertyPermission" "java.rmi.server.ignoreSubClasses" "write")
java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.rmi.server.ignoreSubClasses" "write")
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
	at java.security.AccessController.checkPermission(AccessController.java:884)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at java.lang.System.setProperty(System.java:792)
	at sun.tools.jstatd.Jstatd.main(Jstatd.java:139)  

  解决:

 

#cd /home/jdk-1.8/bin
#vim jstatd.all.policy    

grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
 };

保存
#jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=172.28.37.200 &

4.在windows的java_home/bin下,打开jvisualvm.exe

 

如图,显示CPU不受JVM支持,需要建立jvm链接

 

tomcat下,修改、增加JVM参数

# cd /root/apache-tomcat-8.0.17/bin
# vi catalina.sh   #找到JAVA_OPTS,在下面添加,添加的位置并没要要求
JAVA_OPTS="$JAVA_OPTS-Dcom.sun.management.jmxremote 
        -Dcom.sun.management.jmxremote.port=9999 
        -Dcom.sun.management.jmxremote.authenticate=false 
        -Dcom.sun.management.jmxremote.ssl=false 
        -Djava.rmi.server.hostname=172.28.37.200"
# ./startup.sh 
# netstat -antp |grep 9999    #查看端口是否监听

dubbo服务,修改或增加JVM参数

# vim service.sh
JAVA_OPTS="$JAVA_OPTS-Dcom.sun.management.jmxremote 
        -Dcom.sun.management.jmxremote.port=9999 
        -Dcom.sun.management.jmxremote.authenticate=false 
        -Dcom.sun.management.jmxremote.ssl=false 
        -Djava.rmi.server.hostname=172.28.37.200"

重启后查看端口监听

# netstat -antp |grep 9999    #查看端口是否监听  

重启后,CPU监控已出现

 

posted on 2018-07-21 20:45  冰蓝小猪宝宝  阅读(250)  评论(0编辑  收藏  举报

导航