TDS Tutorial: Getting Started


Installing Java & Tomcat

System requirements

Note: while there are different distributors of Java and servlet containers, Unidata develops, uses and tests the THREDDS Data Server using Sun Java and the Apache Tomcat servlet container.

Installing Java

HOW TO INSTRUCTIONS

Installing the Sun JDK requires three steps:

  1. Download Java from Sun
  2. Install Java
  3. Set the $JAVA_HOME environmental variable
  1. Download current Java SE Developer Kit (JDK) from Sun.
  2. Install the JDK as per the Sun installation instructions.
  3. Set the $JAVA_HOME environment variable.
  4. -bash-3.2$ export JAVA_HOME=/home/thredds/jdk1.6.0_10
    
    -bash-3.2$ echo $JAVA_HOME
    /home/thredds/jdk1.6.0_10
    

Troubleshooting:

Note: the latest version of the JDK 1.6 has already been installed on your workshop computer at /opt/jdk

Installing Tomcat

HOW TO INSTRUCTIONS

Installing Tomcat requires three steps:

  1. Download Tomcat
  2. Install Tomcat
  3. Set the $TOMCAT_HOME environmental variable
  1. Download current version of the Tomcat servlet container.
  2. Install Tomcat as per the Apache Tomcat installation instructions.
  3. Set the $TOMCAT_HOME environment variable.
  4. -bash-3.2$ export TOMCAT_HOME=/home/thredds/apache-tomcat-6.0.18
    
    -bash-3.2$ echo $TOMCAT_HOME
    /home/thredds/apache-tomcat-6.0.18
    

Troubleshooting:

Note: Tomcat has already been installed on your workshop computer at /opt/apache-tomcat-6.0.18

Tomcat directory structure quick tour

Exploring $TOMCAT_HOME

Move into the new Tomcat directory and have a look at the directory structure:

-bash-3.2$ cd apache-tomcat-6.0.18/
-bash-3.2$ ls -l 
total 88
drwxr-xr-x 2 thredds Unidata  4096 2008-11-06 16:45 bin
drwxr-xr-x 2 thredds Unidata  4096 2008-11-06 16:52 conf
drwxr-xr-x 2 thredds Unidata  4096 2008-11-06 16:45 lib
drwxr-xr-x 2 thredds Unidata  4096 2008-11-06 16:47 logs
drwxr-xr-x 2 thredds Unidata  4096 2008-11-06 16:45 temp
drwxr-xr-x 7 thredds Unidata  4096 2008-07-21 18:01 webapps
drwxr-xr-x 3 thredds Unidata  4096 2008-11-06 16:47 work
-rw-r--r-- 1 thredds Unidata 37951 2008-07-21 18:01 LICENSE
-rw-r--r-- 1 thredds Unidata   556 2008-07-21 18:01 NOTICE
-rw-r--r-- 1 thredds Unidata  7317 2008-07-21 18:01 RELEASE-NOTES
-rw-r--r-- 1 thredds Unidata  6587 2008-07-21 18:01 RUNNING.txt

Noteworthy directories

bin/ - Startup, shutdown, and other scripts.

conf/ - Tomcat configuration files.

logs/ - Log files are here by default.

webapps/ - Web applications directories and WAR files.

Running Tomcat

Starting & Stopping Tomcat

Troubleshooting:

Set the $JAVA_HOME, $JAVA_OPTS and $CATALINA_HOME environment variables

We are going to modify the startup.sh and shutdown.sh scripts in the Tomcat /bin directory to:

  1. allow Tomcat to reference/find the location of $JAVA_HOME and $TOMCAT_HOME (aka $CATALINA_HOME) during startup and shutdown; and
  2. increase the amount of memory allocated to the JVM to enhance performance by setting $JAVA_OPTS (-Xms is the initial allocated memory, -Xmx the maximum memory, and -server tells the Hostspot compiler to run the JVM in "server" mode).

Exercise 1. Install Java and Tomcat

  1. Using the steps outlined in the above sections, install the JDK and Tomcat in /home/thredds

Deploying the TDS

HOW TO INSTRUCTIONS

Deploying the TDS requires two steps:

  1. Download the TDS
  2. Put thredds.war in the webapps/ directory
  1. Download the TDS WAR file from Unidata's web site.
  2. thredds.war

  3. Put thredds.war in the Tomcat webapps/ directory.
  4. -bash-3.2$ cp thredds.war /home/thredds/apache-tomcat-6.0.18/webapps
    -bash-3.2$ cd /home/thredds/apache-tomcat-6.0.18/webapps
    
    -bash-3.2$ ls -l
    total 10284
    drwxr-xr-x 11 thredds Unidata     4096 2008-11-06 16:45 docs
    drwxr-xr-x  5 thredds Unidata     4096 2008-11-06 16:45 examples
    drwxr-xr-x  5 thredds Unidata     4096 2008-11-06 16:45 host-manager
    drwxr-xr-x  5 thredds Unidata     4096 2008-11-06 16:45 manager
    drwxr-xr-x  3 thredds Unidata     4096 2008-11-06 16:45 ROOT
    -rw-r--r--  1 thredds Unidata 10491917 2008-11-06 17:08 thredds.war
    

    About WAR files:

  5. Confirm the TDS has been deployed.

Exercise 2. Deploy your own instance of the THREDDS Data Server

  1. Deploy the TDS in your newly-installed Tomcat.
  2. Once deployed, browse the test catalogs & datasets that come with the distribution.

Exercise 3. Implement a shortcut: use setenv.sh to declare $JAVA_HOME, $JAVA_OPTS and $CATALINA_HOME

  1. Stop Tomcat and move into the Tomcat bin/ directory:
  2. -bash-3.2$ cd /home/thredds/apache-tomcat-6.0.18/bin
    -bash-3.2$ ./shutdown.sh
    
  3. Using your favorite text editor, create a new file called setenv.sh:
  4. -bash-3.2$ vi setenv.sh
    
  5. Add the following $JAVA_HOME, $JAVA_OPTS and $CATALINA_HOME environment variable information to the new file:
  6. #!/bin/sh
    #
    # ENVARS for Tomcat and TDS environment
    #
    JAVA_HOME="/home/thredds/jdk1.6.0_10"
    export JAVA_HOME
    JAVA_OPTS="-Xmx1024m -Xms512m -server"
    export JAVA_OPTS
    CATALINA_HOME="/home/thredds/apache-tomcat-6.0.18"
    export CATALINA_HOME
    
  7. Edit the Tomcat startup.sh and shutdown.sh scripts to remove $JAVA_HOME, $JAVA_OPTS and $CATALINA_HOME environment variable information you added previously.
  8. Restart Tomcat and examine the output generated to the terminal window by the startup script:
  9. -bash-3.2$ ./startup.sh
    Using CATALINA_BASE:   /home/thredds/apache-tomcat-6.0.18
    Using CATALINA_HOME:   /home/thredds/apache-tomcat-6.0.18
    Using CATALINA_TMPDIR: /home/thredds/apache-tomcat-6.0.18/temp
    Using JRE_HOME:       /home/thredds/jdk1.6.0_10
    
    -bash-3.2$ less catalina.sh
    

Exercise 4. Look at the log files

  1. Look at the different types of log files being generated in $TOMCAT_HOME/logs.
  2. Examine Tomcat's main log file: catalina.out

Exercise 5. $TOMCAT_HOME

  1. Move into $TOMCAT_HOME and list the directory contents.

 


This document is maintained by Unidata and was last updated on November 5, 2008. Send comments to THREDDS support.