Thursday, June 27, 2013

Liferay 6: Monitoring tomcat.

The Liferay tomcat bundle is available for download on http://www.liferay.com/downloads/liferay-portal/available-releases and instant use. It ships pre-configured with hypersonic database and you can switch to mysql, oracle, etc for permanent solutions.

When moving your site or solution to production server there is always uncertainty on how much the load will be coming at peak time, how many request the tomcat will be able to server with Liferay. Although the Apache tomcat comes with tomcat-manager application that allows you to monitor all the resources via JMX beans. but since this have been removed in Liferay-tomcat bundle thus it is hard to monitor the resources and threads the tomcat server is consuming. Thus to over come this shortcoming, below are the steps to enable the monitoring in the tomcat:

Server Details
Liferay: 6.1.2 GA2 Enterprise
Tomcat Bundle: 7.0.27
Java 6

Step 1:
Stop the running Liferay tomcat server and clean the temp and work folder.

Step 2:
Download the vanilla apache tomcat server of the same version and unzip it at some temporary location.

Step 3:
Copy host-manager and manager application <tomcat>/webapps directory to liferay installation at <liferay-tomcat-bundle>/tomcat-7.0.27/webapps

Step 4:
Create a manager.xml file at location <liferay-tomcat-bundle>/tomcat-7.0.27/conf/Catalina/localhost.
And the following content to it and save it

<Context antiResourceLocking="false" privileged="true" useHttpOnly="true">
 
 </Context>
Step 5:
Now open file <liferay-tomcat-bundle>/tomcat-7.0.27/conf/tomcat-users.xml in edit mode. And the below content inside the tag <tomcat-users>.

<tomcat-users>
...

  <role rolename="tomcat"/>
  <role rolename="manager-gui"/>
  <role rolename="standard"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="manager,admin,standard,manager-gui,tomcat"/>

...
</tomcat-users>

Step 6:
Now restart the tomcat server and go to the URL: http://localhost:8080/manager/html and you will be prompted for username and password which should be the same as defined above.



And now you can monitor the tomcat resources and can tune them accordingly.