jump to navigation

Revving up Geoserver on Ubuntu HH LTS November 10, 2008

Posted by grimmeister in Geoinformatics.
Tags: ,
5 comments

Given my setup described at revisiting-geoserver-on-ubuntu
, I am slowly learning (with Tim Sutton) good and weird lessons on how to make geoserver really punch out those services…

No question, you have to do a few things. Geoserver out of the box is relatively minimalist. So a few things need attention, many outlined in the *geoserver in a production environment pages* of the website.

1) Make sure you are using the server jvm.

UPDATE: see Andrea’s comments – the server VM automatically kicks in if you have a server class machine, and configures resource allocation similar to what is described in point 2.

Many docs, including those at Geoserver suggest using a -server flag for the tomcat daemon. This is rather mystifying to myself and others, because Tomcat will not start on our systems if we have this flag set. So my conclusion is that the -server flag is inbuilt into server class machines, or in the Ubuntu 64 bit environment, it is just not available.

I suspect that the kind folk at Ubuntu have distributed the various server flavours with the server jvm as default. To check, type at prompt:

java -server -version

you should receive back something like :

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed mode)

If you get this, you will notice in the file /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/amd64/jvm.cfg that the server option is default.

If you do not get this message , it is likely that you have not got the sun jdk installed for your server, so fetch and install it, make sure the jdk /bin is first to be found on the path, then repeat the above test.

So the question you really need to answer, is whether /usr/bin/jsvc (commons-daemon on Debian/Ubuntu) is hitting the appropriate JVM.

A question that bothers me a bit is whether there is even a -server flag on 64 bit Ubuntu. This configuration step may be pointless. Seems odd, but my readings have hinted that it is not an option on AMD64 architectures. Given Ubuntu 64 bit seems to work on X86 and AMD64 systems, is it possible that an artifact is a missing -server flag

A little bit vague I know, but may give you enough of a hint to get it working fully.

2) Throw resources at Tomcat

From the get-go give tomcat lots of resources (depending on what else is running on your system). Do this in your tomcat daemon script ( /etc/init.d/tomcat5.5) JAVA_OPTS section. JAVA_OPTS="-Djava.awt.headless=true -Xms144m -Xmx768M -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:MaxPermSize=256m -XX:XX:+UseParallelGC" So, I have set the minimum heap size to 144Mb of memory, maxing out at 768Mb and giving the JVM space to move. I have increased the perm gen space to 256 Mb to aid in classloading and have made use of my multiprocessor setup for garbage collection. There are loads of options available – I am certainly not sure if I am properly optimised here at all.

3) Sessions

I have been grappling a fair amount with a particular issue around Tomcat sessions spiralling out of
control for the geoserver context.

So, make sure (if you are using tomcat, and this seems to be a problem) that you add or modify
the /webapps/geoserver/WEB-INF/web.xml file to include:

<session-config>
<session-timeout>1</session-timeout>
</session-config>

This prevents sessions from being kept alive when idle for more than a
minute. Geoserver does not need them apparently. Be aware that you should probably only do this once your geoserver config is happy – otherwise you will be logging in a lot 😦
4) Logging

make sure to set the log level to PRODUCTION-LOGGING.properties in the server part of the config.

5) Tile Cache

If you are serving WMS, put a tile cache of some variety up in order to reduce the load on the database and geoserver. MetaCarta’s TileCache, GeoWebCache, OSCache, even something like Squid could be used. I have not set it up a tile cache yet, but will add details if and when when I do so (my WMS’s data tend to change quite a lot)

6) Apache Portable Run Time library with Tomcat

The use of this library allows certain aspects of tomcat to be enhanced, with performance gains of 10% or so reported. I guess it would depend on what you were serving!

Binaries for this library can be found, but it is better to compile from source ( with some help from http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Tomcat+Native+Library ).

Make sure that you have the libssl-dev and libapr1-dev packages installed ( sudo apt-get install libssl-dev libapr1-dev)

http://apache.seekmeup.com/tomcat/tomcat-connectors/native/1.1.15/source/tomcat-native-1.1.15-src.tar.gz is some source code

Extract the tarball of the tomcat native lib (tar -xvzf tomcat-native.tar.gz)

cd tomcat-native-1.1.5/jni/native

Configure ./configure --with-apr=/usr --with-java-home=/usr/lib/jvm/java-6-sun-1.6.0.06 (or wherever your jdk lives)

Make and install (sudo make && sudo make install) – generates the library and symlinks in /usr/local/apr/lib

Change to the system library folder ( cd /usr/lib )

Make a symlink to the library  (sudo ln -s /usr/local/apr/lib/libtcnative-1.so libtcnative-1.so)

Edit ${TOMCAT_HOME}/bin/catalina.sh adding the following lines somewhere before java is executed ( LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH )

Restart Tomcat and make sure to check your logs for success or failure. It seems that failure may likely result from problems with IPv6 enabled machines. Disable IPv6 ( edit /etc/modprobe.d/aliases and change the linealias net-pf-10 ipv6toalias net-pf-10 off ipv6 and reboot ) if you can.

7) Native JAI rather than the pure java JAI

This applies in particular if one is attempting to serve raster data, perhaps some satellite imagery but per Andrea’s comment is valuable for improving WMS generation too. So:

fetch the libraries. I got myself the ones from http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-amd64.tar.gz

After unpacking the tarball, I copied the 3 jar files:

sudo cp jai-1_1_3/lib/*.jar  /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/ext

and the shared library:

sudo cp jai-1_1_3/lib/libmlib_jai.so  /usr/lib/jvm/java-6-sun-1.6.0.06/bin

then restarted Tomcat. JAI appears as available on the Geoserver Admin page.

Advertisements

Well Done USA November 5, 2008

Posted by grimmeister in Uncategorized.
Tags:
add a comment

I think many folk in South Africa were most pleased to see Barack Obama become President-Elect. I listened in on his victory speech and was really overwhelmed by it (I have not heard him speak too many times, so maybe it is his normal style). It felt Mandela-esque to me – wise, kind, rounded yet persuasive. It struck me that even if the current state of the world prevents him from achieving his visions, his call to people to change the way the see things is what is most compelling. He seems to make politics just a little more personal, as if a small person can do big things.

Yes Please!