Archive for March, 2011

Zimbra OSE 7, Java tuning for OpenVZ instance.

Posted in HowTo on 12/03/2011 by Undersys

I recently did an upgrade to my hosted Zimbra server. The host uses OpenVZ you can read this post by me to see why it sucks for Zimbra or any heavy Java apps.
I am not using OpenVZ by choice its what my VPS is using..

The upgrade went smooth in the sense that I could log in and read and use the system.
I noticed that “zmstatuslog” scrip would keep failing , with errors around been unable to create the Java VM.
Meaning that because of the architecture of OpenVZ the Zimbra process in question was not able to grab a contigious block of memory for the size it was asking. Thats why we are about to reduce the size it asks for. Only on a select process. Do keep in mind this negatively effects performance. Thats ok for my small mail server. Back to the issue..

When “zmstauslog” runs it calls “zmlocalconfig” to see what services where running.

Sounds good.. Unfortunately the Java enviroment settings are not passed to “zmlocalconfig” from the “localconfig.xml”
The only real setting I need is the “-xmx” to set the max Java heap size small enough that it won’t crash. In my case I set it to 8mb,  as the “zmlocalconfig” script is not very intense.

You do this by editing the file:-
/opt/zimbra/bin/zmlocalconfig

I added changed the following two lines to include the -xmx” setting” :-

java_options=”-Xmx8m -XX:ErrorFile=${ZMROOT}/log”
java_options=”-Xmx8m”

I also noticed after the upgrade “memcachd” and “imapproxy” where enabled and running.
Since I only have one serve they are not needed.
Turn them off by doing the following as the “zimbra” user :-

# zmcontrol stop
# zmprov ms `zmhostname` -zimbraServiceEnabled imapproxy
# zmprov ms `zmhostname` -zimbraServiceEnabled memcachd
# zmcontrol start

If your still having issues after this, see my previous article or tune down the following setting in  :-
/opt/zimbra/conf/localconfig.xml

<key name=”zimbra_zmjava_options”>
<value>-Xms128m -Xmx128m</value>
</key>

I’ve got mine set at 128m as this will affect over applications inside Zimbra so you don’t want to set it too small.
It can also be set as the Zimbra user via this command :-
# zmlocalconfig -e  zimbra_zmjava_options=”-Xms128m -Xmx128m”