geoserver setup - linux

introduction

This page tells you how to install Geoserver.

We use Geoserver to create nice map images from all manner of sources.

It creates images from vectors, styles vectors, labels roads, styles labels, overlays vectors on top of images, etc.

It also provides a way to cache the images (or layers) it generates - geowebcache.

It is CPU intensive, requires lots effort to set up, but once setup, it is the bomb.

Because it is CPU intensive, we take all measures recommended by Geoserver to improve performance.

java

The Geoserver team strongly recommends using the latest proprietary sun JDK.

Some open source linux distros use a non Sun JVM/JDK.

If so, install Sun Java.

How do you know what java VM you have?

$ java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)
$

If you do not know where java is installed:

$ which java
path_is_echoed_to_screen

java installation (linux)

"Alternatives" is one way that to allow multiple versions of JVMs to run on a single host.
We do not have to use the alternatives framework - in fact for the tomcat init, we point to the jdk/jre directly.
todo - Could use some best practices here.

These instructions seemed to work reasonably well in at least one instance.

In another instance, these worked better.

java advanced imaging (JAI)

To get the best performance, be sure to install the JAI libraries.

Read about that here.

In one case I installed manually

  • download the tar ball
  • put the jars in the right place ($JAVA_HOME/jre/lib/ext)
  • put the "so" file in the right place ($JAVA_HOME/jre/lib/i386)

In another case this worked nicely

  • install java jdk not jre only
    • if you use jre only subsequent step fails
  • download the jai jre package
    • wget "http://download.java.net/media/jai/builds/release/1_1_3/jai-1_1_3-lib-linux-i586-jre.bin"
  • cd into your JDK's jre dir
  • run /bin/sh /tmp/jai-1_1_3-lib-linux-i586-jre.bin
    Is this a little bit counter-intuitive to you too?

java fonts

To get the nice fonts you are used to you need to install them on linux systems.

The styles we wrote for sfmaps uses arial - and was developed using the microsoft true type fonts.

These pages tell you how to install the ms font set on linux:

Of course it's never all that easy to just follow instructions.

I encountered a few dependency issues - often going down multiple layers.

I am not documenting because I think this will be slightly different on any given system.

tomcat

After installing java, try to start tomcat.

In one case tomcat did not start.

I had to run "prelink".

$ yum install prelink
$ prelink --all

todo - is this section right for applogic?

Create a tomcat user and group, ideally, for security reasons, one that does not allow login.

Set JAVA_HOME and PATH on the tomcat user account:

If not in 3tera, setup tomcat daemon.

How?

TODO - applogic school
Make sure tomcat is run under tomcat user (appliance.sh)

TODO - applogic school
When want geoserver to have lots of memory, so we need to make sure the JVM under tomcat has the right JAVA_OPTS -Xmx. Is this simply set in the UI resources? Right now the MAX is at 64GB - which seems wrong. Someone spent a lot of time trying to intelligently pick an Xmx value in /appliance/appliance.sh. In any case, we want something right around 2-4GB here. Beyond that and GC may be overworked?

tomcat native acceleration

Concensus is that tomcat native acceleration is worth the trouble.

Here is how to do it.

$ yum search tomcat | sort | uniq

$ sudo yum install tomcat-native.i386

Be sure the cfg file points to the native lib:

JAVA_OPTS="-Djava.library.path=/usr/local/apr/lib/libtcnative-1.so"

TODO - how to handle JAVA_OPTS in applogic?

I hard coded this in appliance.sh

add /usr/local/apr/lib/ to LD_LIBRARY_PATH in tomcat startup

The procedure for windows is slightly different - you obtain a dll and copy it to the right location.

Inspect tomcat log file to make sure it's working.

Running tomcat at boot up

append the line to /etc/rc.d/rc.local

tomcat5 start

tomcat logging

TODO - logging should say when it is using tcnative or not.

3tera does not cfg tomcat to log anything out of the box.

We want some container level logging

Geoserver takes care of its own logging.

tomcat test

To make sure it's working, ssh onto the host and

wget http://localhost:8080/

If there is no root page, wget will return an error, but you should see evidence of a connection.

To debug

netstat -apn | grep 8080

and make sure there is a java process and see what port it is listening on.

tomcat configuration

The tomcat server configuration file is called server.xml.

I had some problem in applogic, because we need to listen using localhost.

How to do this was was inobvious until you learn how - funny that.

Here is the applogic server.xml that I want. I have added line 7.

1 <?xml version="1.0" encoding="UTF-8"?>
2 <Server port="8005" shutdown="SHUTDOWN">
3   <GlobalNamingResources>
4   </GlobalNamingResources>
5   <Service name="Catalina">
6     <Connector port="8080" maxThreads="100" address="in" />
7     <Connector port="8080" maxThreads="100" address="localhost" />
8     <Connector port="8009" protocol="AJP/1.3" address="in" />
9     <Engine name="Catalina" defaultHost="localhost">
10       <Host name="localhost" appBase="webapps">
11       </Host>
12     </Engine>
13   </Service>
14 </Server>

To make this happen we must add a new line in /appliance/appliance.sh bettwen 171 and 172.

171 config[$index]="    <Connector port=\"${_tomcat_port}\" maxThreads=\"${_max_connections}\" address=\"in\" />" && ((index++))
    config[$index]="    <Connector port=\"${_tomcat_port}\" maxThreads=\"${_max_connections}\" address=\"localhost\" />" && ((index++))
172 config[$index]='    <Connector port="8009" protocol="AJP/1.3" address="in" />' && ((index++))

geoserver introduction

install

Download the war file, and drop it into the TOMCAT webapps dir.
Put the data dir in a separate location.

Finally copy the configuration files into geoserver_configuration.

paletted images

We use a paletted images to improve map image quality and maintain performance.

applogic introduction

applogic startup sequence

  • /appliance/appliance.sh
    • overwrites /appliance/tomcat/conf/server.xml (1)
    • sets tomcat port and max connections
    • sources /etc/applogic.sh
      • /etc/applogic.sh: key value paris written from applogic UI
      • where does the UI application store data?
      • sets tomcat port to 8080
    • set and export JAVA_OPTS
    • calls /usr/apache-tomcat-5.5.27/bin/startup.sh
      • calls ./catalina.sh
        • calls ./setclasspath.sh
        • set JAVA_HOME
        • set JRE_HOME
        • set CATALINA_HOME
        • set CLASSPATH
        • execute java - tomcat startup

(1) but does not add in server-minimal.xml
this is why it does not listen on localhost!

applogic file system

The tomcat home is here

  • /appliance/tomcat
    which contain symlinks to
  • /mnt/fs/prod_app/
    which is where we see web_apps and the like.

read more