Tuesday 24 July 2012

Configuring VisualVM with tomcat + linux

VisualVM is a tool that provides a visual interface for viewing detailed information about Java applications while they are running on a Java Virtual Machine (JVM), and for troubleshooting and profiling these applications.

Firs of all you need to configure JMX. For tomcat you need to perform this:

  1. In folder %CATALINA_HOME%/conf need to create remote.users with content:
    USER_1 PASSWORD_2
    USER_2 PASSWORD_2
    
  2. In folder %CATALINA_HOME%/conf need to create remote.acl with content:
    USER_1 PERMISSION_1
    USER_2 PERMISSION_2
    
    where permissions: readonly, readwrite 
  3. chmod 400 remote.users
  4. chmod 400 remote.acl
  5. chown tomcat:tomcat remote.users
  6. chown tomcat:tomcat remote.acl
  7. In tomcat %CATALINA_HOME%/bin/catalina.sh need to add:  
    CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.password.file=/opt/tomcat/conf/remote.users 
    -Dcom.sun.management.jmxremote.access.file=/opt/tomcat/conf/remote.acl -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.port=7777 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Djava.rmi.server.hostname=1.1.1.1"
    
    where hostname - is tomcat server ip, and port - any not used port
  8. Restart Tomcat
  9. Visual VM comes with JDK from 6u7, run it on your local machine $JAVA_HOME/bin/jvisualvm 
  10. Click File->Add JMX connection use user, password, host and port
  11. Will appear new perspective whith your server connection

1 comment: