29
http://www.unidata.ucar.edu/projects/ THREDDS/tech/tutorial/ GettingStarted.html providing innovative data services and tools to transform the conduct of geoscience Data o Available Data Types o Forecast Model Output o Satellite Data o Radar Data o Lightning Data o Wind Profiler Data o Aircraft-Borne (ACARS) o GPS Meteo. Data (SuomiNet) o Textual Weather Bulletins o Data Resources o Data Usage Guide o LDM Feedtypes o IDD Operational Status o Archived Data Access Software o Display & Analysis o AWIPS II o GEMPAK o IDV o McIDAS o Data Access & Management o LDM o LDM-McIDAS Decoders o LibCF o NetCDF o NetCDF/GRIB Decoders o NetCDF Java o NetCDF Perl

Tomcat Linux

Embed Size (px)

DESCRIPTION

tomcat linux

Citation preview

Page 1: Tomcat Linux

http://www.unidata.ucar.edu/projects/THREDDS/tech/tutorial/GettingStarted.html

providing innovative data services and tools to transform the conduct of geoscience

Data o Available Data Typeso Forecast Model Output o Satellite Data o Radar Data o Lightning Data o Wind Profiler Data o Aircraft-Borne (ACARS) o GPS Meteo. Data (SuomiNet) o Textual Weather Bulletins o Data Resourceso Data Usage Guide o LDM Feedtypes o IDD Operational Status o Archived Data Access

Software o Display & Analysiso AWIPS II o GEMPAK o IDV o McIDAS o Data Access & Managemento LDM o LDM-McIDAS Decoders o LibCF o NetCDF o NetCDF/GRIB Decoders o NetCDF Java o NetCDF Perl o RAMADDA o THREDDS Data Server o UDUNITS

Downloads o Download Softwareo GEMPAK o IDV o McIDAS o LDM

Page 2: Tomcat Linux

o LDM-McIDAS Decoders o NetCDF o NetCDF/GRIB Decoders o NetCDF Java o NetCDF Perl o RAMADDA o TDS o UDUNITS o Terms & Conditionso Provision of Software

Support o Support Resourceso Documentation o Training Tutorials o Mailing Lists o Support Archives o Submit a Requesto Suggested Support Process o Email-Based o Web-Based o Terms & Conditionso Obtaining Support o Register as a User

Community o Outreach & Opportunitieso News from Unidata o Unidata Events o News from the Community o Job Opportunities o DeSouza Award o Equipment Awards o We Are Community Driveno Participating Institutions o Collaborations o Education Resources o Software & Data in Use o How to Participate o Governanceo Policy Committee o Users Committee o Publications & Resourceso Bibliography o Glossary of Terms

Projects o Current Projects

Page 3: Tomcat Linux

o CADIS o Case Studies o Common Data Model o CONDUIT o GALEON o GEON IDV o Google Africa Initiative o GRIDSPEC o HYDRO-NEXRAD o Internet Data Distribution o McIDAS-V o Data Intercomparisons o Next-Generation LDM o OPULS o Tropical Cyclone IDV

News o News from Unidatao News from Unidata o Unidata Events o News from the Communityo News From the Community o Community Jobs o News Archiveso Archived CommunitE-letters o Archived News Releases

Events o 2012 EarthCube Workshop o Unidata Eventso Calendar of Events o Seminar Series o Conferences & Meetings o Unidata Workshopso Training Workshops o Triennial Workshops o Regional Workshops o Data Workshops

About Us o The Unidata Programo Overview of Unidata o Highlights & Reports o Unidata Leaflet o Unidata Director's Page o Our Organizationo Working Groups o Reporting Structure

Page 4: Tomcat Linux

o Staff Listing o Contact Unidatao Contact Information o Visit Unidata

TDS Workshop Home Getting Started with Tomcat, Java and the TDS

Getting Started with Tomcat, Java and the TDS

Installing Java and Tomcat

System requirements

JDK Installation help

Users of GCJ and OS-provided packages (linux) for Java and/or Tomcat may want to reference the THREDDS mailing list for installation help.

Sun Java 7 (latest version) Apache Tomcat 7.x

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

1. Download current Java SE Developer Kit (JDK) from Sun. Use the latest 1.7 version of the JDK.

At the time of this workshop, that is version Java SE 7u9. We will be using the Linux x64-bit tar.gz file:

jdk-7u9-linux-x64.tar.gz

2. Install the JDK as per the Sun installation instructions.

Copy the binary tar.gz file into the installation directory (/home/tds/GettingStarted/ in this example):

site:www .unidat 00842466462294 FORID:9 UTF-8

Page 5: Tomcat Linux

$ pwd

/home/tds

$ ls -l

drwxr-xr-x 2 tds ustaff 4096 Oct 9 14:02 Desktop

drwxr-xr-x 2 tds ustaff 4096 Oct 9 12:55 Documents

drwxr-xr-x 2 tds ustaff 4096 Oct 19 17:49 Downloads

drwxr-xr-x 14 tds ustaff 4096 Oct 19 16:02 epd

drwxr-xr-x 2 tds ustaff 4096 Oct 8 15:52 GettingStarted

drwxr-xr-x 2 tds ustaff 4096 Oct 9 12:55 Music

drwxr-xr-x 2 tds ustaff 4096 Oct 9 13:48 netcdf-java-4.3

drwxr-xr-x 2 tds ustaff 4096 Oct 9 12:55 Pictures

drwxr-xr-x 2 tds ustaff 4096 Oct 9 12:55 Public

drwxr-xr-x 2 tds ustaff 4096 Oct 9 12:55 Templates

drwxr-xr-x 2 tds ustaff 4096 Oct 9 12:55 Videos

drwxr-xr-x 2 tds ustaff 4096 Oct 19 17:52 workshop

$ cp Downloads/jdk-7u9-linux-x64.tar.gz GettingStarted/

$ ls -l GettingStarted/

-rw-r--r-- 1 tds ustaff 96043498 Oct 19 17:56 jdk-7u9-linux-x64.tar.gz

Move into the installation directory and unpack the archive file:

$ cd GettingStarted/

$ pwd

/home/tds/GettingStarted

Page 6: Tomcat Linux

$ ls -l

-rw-r--r-- 1 tds ustaff 96043498 Oct 19 17:56 jdk-7u9-linux-x64.tar.gz

$ tar zxvf jdk-7u9-linux-x64.tar.gz

This will extract the JDK in the installation directory:

$ ls -l

drwxr-xr-x 8 tds ustaff 4096 Sep 24 21:38 jdk1.7.0_09

-rw-r--r-- 1 tds ustaff 96043498 Oct 19 17:56 jdk-7u9-linux-x64.tar.gz

Troubleshooting

Depending on your OS you may need install either the 32-bit or 64-bit version of the JDK.

Installing Tomcat

Tomcat on Windows

For more information about installing Tomcat on Windows OS, see the Tomcat setup guide for installation on different platforms.

1. Download current version of the Tomcat 7 servlet container.

At the time of this workshop, that is version 7.0.32. We will be using the binary tar.gz file:

apache-tomcat-7.0.32.tar.gz

2. Install Tomcat as per the Apache Tomcat installation instructions.

Copy the binary tar.gz file into the installation directory (/home/tds/GettingStarted/ in this example):

$ pwd

/home/tds/GettingStarted

Page 7: Tomcat Linux

$ cp ~/Downloads/apache-tomcat-7.0.32.tar.gz .

$ ls -l

-rw-r--r-- 1 tds ustaff 7701019 Oct 19 17:59 apache-tomcat-7.0.32.tar.gz

drwxr-xr-x 8 tds ustaff 4096 Sep 24 21:38 jdk1.7.0_09

-rw-r--r-- 1 tds ustaff 96043498 Oct 19 17:56 jdk-7u9-linux-x64.tar.gz

Unpack the archive file:

$ tar xvzf apache-tomcat-7.0.32.tar.gz

This will create a Tomcat directory:

$ ls -l

drwxr-xr-x 9 tds ustaff 4096 Oct 19 18:00 apache-tomcat-7.0.32

-rw-r--r-- 1 tds ustaff 7701019 Oct 19 17:59 apache-tomcat-7.0.32.tar.gz

drwxr-xr-x 8 tds ustaff 4096 Sep 24 21:38 jdk1.7.0_09

-rw-r--r-- 1 tds ustaff 96043498 Oct 19 17:56 jdk-7u9-linux-x64.tar.gz

Exercise One: Install Java and Tomcat

Using the steps outlined in the above sections, install the JDK and Tomcat in /home/tds/GettingStarted

Tomcat Directory Structure: Quick Tour

Exploring the Tomcat directory structure

1. Examine the Tomcat directory structure, aka ${tomcat_home}.

Move into ${tomcat_home} and do a long listing:

$ cd apache-tomcat-7.0.32

$ ls -l

drwxr-xr-x 2 tds ustaff 4096 Oct 19 18:00 bin

Page 8: Tomcat Linux

drwxr-xr-x 2 tds ustaff 4096 Oct 3 01:52 conf

drwxr-xr-x 2 tds ustaff 4096 Oct 19 18:00 lib

-rw-r--r-- 1 tds ustaff 56812 Oct 3 01:52 LICENSE

drwxr-xr-x 2 tds ustaff 4096 Oct 3 01:51 logs

-rw-r--r-- 1 tds ustaff 1192 Oct 3 01:52 NOTICE

-rw-r--r-- 1 tds ustaff 8826 Oct 3 01:52 RELEASE-NOTES

-rw-r--r-- 1 tds ustaff 15557 Oct 3 01:52 RUNNING.txt

drwxr-xr-x 2 tds ustaff 4096 Oct 19 18:00 temp

drwxr-xr-x 7 tds ustaff 4096 Oct 3 01:52 webapps

drwxr-xr-x 2 tds ustaff 4096 Oct 3 01:51 work

2. Familiarize yourself with the following important directories.

bin/

o Contains startup.sh, shutdown.sh and other scripts/programs.

o The *.sh files (for Unix systems) are functional duplicates of the *.bat files (for Windows systems).

conf/

o Server-wide Tomcat configuration.

o You will modify server.xml and tomcat-users.xml to adjust logging, authentication and access control, enable SSL, etc.

o Web applications can override some server-wide settings in their own configuration files (more about that later).

webapps/

o Contains web applications directories and WAR files.

o This is where we will be putting the TDS web application.

o You will also be using the manager application that comes with Tomcat during this workshop.

logs/

o Tomcat log files are here by default.

Page 9: Tomcat Linux

o This is one of the directories you will be looking for log files (the TDS logs elsewhere by default).

o The log files should be your first stop for troubleshooting Tomcat and TDS issues. (Hint, hint.)

o Logs files may contain useful information for assessing the security of your system.

o You will become very familiar with the Tomcat-generated catalina.out, catalina.yyyy-mm-dd.log and localhost_access_log.yyyy-mm-dd.log files by the end of this workshop.

Running Tomcat

Starting & stopping Tomcat

1. Tomcat isn't currently running so we need to start it up.

Run the startup.sh script in the Tomcat bin/ directory:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32

$ bin/startup.sh

2. Verify Tomcat is running.

Look and see if you have a Tomcat process running:

$ ps -ef | grep tomcat

tds 2688 1 5 11:01 pts/1 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/home/tds/GettingStarted/apache-tomcat-7.0.32/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/tds/GettingStarted/apache-tomcat-7.0.32/endorsed -classpath /home/tds/GettingStarted/apache-tomcat-7.0.32/bin/bootstrap.jar:/home/tds/GettingStarted/apache-tomcat-7.0.32/bin/tomcat-juli.jar -Dcatalina.base=/home/tds/GettingStarted/apache-tomcat-7.0.32 -Dcatalina.home=/home/tds/GettingStarted/apache-tomcat-7.0.32 -Djava.io.tmpdir=/home/tds/GettingStarted/apache-tomcat-7.0.32/temp org.apache.catalina.startup.Bootstrap start

tds 2711 2197 0 11:02 pts/1 00:00:00 grep tomcat

Open a new browser window/tab and go to http://localhost:8080/ to verify Tomcat is running:

Page 10: Tomcat Linux

3. See if you can shutdown Tomcat.

Run the shutdown.sh script in the Tomcat bin/ directory:

$ bin/shutdown.sh

Which Java is Tomcat currently using? (Hint: what was sent to STDOUT when running the startup.sh and shutdown.sh?)

Troubleshooting

Check the logs mostly recently generated in the Tomcat logs for clues about why Tomcat failed to start or stop. Pay particular attention to what is being reported in Tomcat's main log file: catalina.out.

Setting $JAVA_HOME, $JAVA_OPTS and $CATALINA_BASE

Tomcat on Windows

If you're running Tomcat on an instance of Windows OS, you will want to create a setenv.bat file.

We are going to create a file called setenv.sh in the Tomcat bin/ directory to:

allow Tomcat to reference/find the location of $JAVA_HOME and $CATALINA_BASE) during startup and shutdown;

increase the amount of memory allocated to the JVM to enhance performance by setting $JAVA_OPTS; and

add additional settings to the JVM via $JAVA_OPTS to enable more advanced services we will be learning about later on in this workshop.

Page 11: Tomcat Linux

1. Create the setenv.sh file.

Using your favorite text editor (gedit, vi, emacs, etc.), create a new file called setenv.sh in the Tomcat bin/ directory:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32

$ cd bin

$ vi setenv.sh

Add the following information and save your setenv.sh file:

#!/bin/sh

#

# ENVARS for Tomcat and TDS environment

#

JAVA_HOME="/home/tds/GettingStarted/jdk1.7.0_09"

export JAVA_HOME

CATALINA_BASE="/home/tds/GettingStarted/apache-tomcat-7.0.32"

export CATALINA_BASE

JAVA_OPTS="-Xmx4096m -Xms512m -server -Djava.awt.headless=true -Djava.util.prefs.systemRoot=$CATALINA_BASE/content/thredds/javaUtilPrefs"

export JAVA_OPTS

Settings

Whenever possible, Unidata recommends -Xmx1500m for 32-bit systems, and-Xmx4096m (or more) for 64-bit systems.

Looking Ahead

Page 12: Tomcat Linux

You will learn more about the TDS Web Map Service (WMS) later on in this workshop.

The parameters we pass to $JAVA_OPTS:

o -Xms is the initial allocated memory of the JVM (for performance).

o -Xmx the maximum allocated memory of the JVM (for performance).

o -server tells the Hostspot compiler to run the JVM in "server" mode.

o -Djava.awt.headless=true is needed to prevent graphics rendering code from assuming a graphics console exists. Without this, WMS code will crash the server in some circumstances.

o -Djava.util.prefs.systemRoot=$CATALINA_BASE/content/thredds/

javaUtilPrefs allows the java.util.prefs of the TDS WMS to write system preferences to a location that is writable by the Tomcat user.

2. Implement your changes by restarting Tomcat.

Restart Tomcat and examine the output generated to the terminal window by the startup script:

$ ./startup.sh

Using CATALINA_BASE: /home/tds/GettingStarted/apache-tomcat-7.0.32

Using CATALINA_HOME: /home/tds/GettingStarted/apache-tomcat-7.0.32

Using CATALINA_TMPDIR: /home/tds/GettingStarted/apache-tomcat-7.0.32/temp

Using JRE_HOME: /home/tds/GettingStarted/jdk1.7.0_09

Using CLASSPATH: /home/tds/GettingStarted/apache-tomcat-7.0.32/bin/bootstrap.jar:/home/tds/GettingStarted/apache-tomcat-7.0.32/bin/tomcat-juli.jar

Did you notice any difference in the what is being reported to STDOUT during startup?

Take a look at the running Tomcat process to see the new $JAVA_OPTS settings:

$ ps -ef | grep tomcat

tds 2819 1 28 11:17 pts/1 00:00:02 /home/tds/GettingStarted/jdk1.7.0_09/bin/java -Djava.util.logging.config.file=/home/tds/GettingStarted/apache-tomcat-7.0.32/conf/logging.properties -Xmx4096m -Xms512m -server -Djava.awt.headless=true -Djava.util.prefs.systemRoot=/home/tds/GettingStarted/apache-tomcat-7.0.32/content/thredds/javaUtilPrefs -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/tds/GettingStarted/apache-tomcat-7.0.32/endorsed -classpath /home/tds/GettingStarted/apache-tomcat-7.0.32/bin/bootstrap.jar:/home/tds/GettingStarted/apache-tomcat-7.0.32/bin/tomcat-juli.jar -Dcatalina.base=/home/tds/GettingStarted/apache-tomcat-7.0.32 -Dcatalina.home=/home/tds/GettingStarted/apache-tomcat-7.0.32 -

Page 13: Tomcat Linux

Djava.io.tmpdir=/home/tds/GettingStarted/apache-tomcat-7.0.32/temp org.apache.catalina.startup.Bootstrap start

Environment Variables

For more information on the environment variable prerequisites used by Tomcat, consult ${tomcat_home}/bin/catalina.sh (or catalina.bat) file.

What allows us to create the setenv.sh file and have its contents read? (Hint: have a look at the catalina.sh file in the Tomcat bin/ directory at lines 24 and 133).

Troubleshooting

o Do not forget include the 'm' in your -Xms and -Xmx settings.

o You may have allocated too much memory for the JVM settings if Tomcat fails to start and you get the following error reported in the Tomcat log catalina.out:

Error occurred during initialization of VM

Could not reserve enough space for object heap

o Likewise, if there is an error with your JVM memory allocation syntax in the setenv.sh file, it will be reported to catalina.out:

Error occurred during initialization of VM

Incompatible minimum and maximum heap sizes specified

o If you intend to use WMS and see something like the following in reported in catalina.out:

May 25, 2010 6:28:22 PM java.util.prefs.FileSystemPreferences syncWorld

WARNING: Couldn't flush system prefs: java.util.prefs.BackingStoreException: /etc/.java/.systemPrefs/org create failed.

You will need to set the java.util.prefs.systemRoot system property in $JAVA_OPTS to a location that is writable by the user that Tomcat, e.g.:

#!/bin/sh

#

# ENVARS for Tomcat and TDS environment

#

JAVA_HOME="/home/tds/GettingStarted/jdk1.7.0_09"

export JAVA_HOME

Page 14: Tomcat Linux

CATALINA_BASE="/home/tds/GettingStarted/apache-tomcat-7.0.32"

export CATALINA_BASE

JAVA_OPTS="-Xmx4096m -Xms512m -server -Djava.awt.headless=true -Djava.util.prefs.systemRoot=$CATALINA_BASE/content/thredds/javaUtilPrefs"

export JAVA_OPTS

Exercise Two: Set $JAVA_HOME, $JAVA_OPTS and $CATALINA_BASE

1. Create a setenv.sh file in the Tomcat bin/ and set $JAVA_HOME, $JAVA_OPTS and $CATALINA_BASE.

Deploying the TDS

About WAR files

WAR is short for Web ARchive. By default, Tomcat will automatically unpack the WAR distribution into directory of the

same name upon deployment. Note: the unpacked directory is overwritten each time a new WAR file is deployed.

Downloading & deploying thredds.war

Upgrading the TDS

A maintenance checklist and contains helpful information about upgrading the TDS. New features and configuration changes made between TDS versions are listed for each release.

1. Download the TDS WAR file from Unidata's web site.

We will be using the current TDS 4.3 (release candidate) version for this workshop:

thredds.war

2. Deploy the TDS in Tomcat.

Put thredds.war in the Tomcat webapps/ directory:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32/bin

Page 15: Tomcat Linux

$ cd ../webapps

$ cp ~/Downloads/thredds.war .

$ ls -l

drwxr-xr-x 13 tds ustaff 4096 Oct 19 18:00 docs

drwxr-xr-x 6 tds ustaff 4096 Oct 19 18:00 examples

drwxr-xr-x 5 tds ustaff 4096 Oct 19 18:00 host-manager

drwxr-xr-x 5 tds ustaff 4096 Oct 19 18:00 manager

drwxr-xr-x 3 tds ustaff 4096 Oct 19 18:00 ROOT

-rw-r--r-- 1 tds ustaff 40444990 Oct 19 18:10 thredds.war

3. Confirm the TDS has been deployed.

If Tomcat is already running, wait a couple of seconds after placing the WAR file in the Tomcat webapps/ and then verify the thredds.war file was unpacked:

$ ls -l

drwxr-xr-x 13 tds ustaff 4096 Oct 19 18:00 docs

drwxr-xr-x 6 tds ustaff 4096 Oct 19 18:00 examples

drwxr-xr-x 5 tds ustaff 4096 Oct 19 18:00 host-manager

drwxr-xr-x 5 tds ustaff 4096 Oct 19 18:00 manager

drwxr-xr-x 3 tds ustaff 4096 Oct 19 18:00 ROOT

drwxr-xr-x 8 tds ustaff 4096 Oct 19 18:10 thredds

-rw-r--r-- 1 tds ustaff 40444990 Oct 19 18:10 thredds.war

Go to http://localhost:8080/thredds/ in your browser to verify the TDS has been deployed:

Page 16: Tomcat Linux

Troubleshooting

o Any error in the TDS deployment will be reported in the catalina.out file of the Tomcat logs/ directory.

o Be sure you have downloaded and deployed the TDS 4.3 (release candidate) version for this workshop (the version number will appear in the blue bar at the bottom of TDS catalog pages).

Exercise Three: 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.

3. Look at the directory contents of the main Tomcat directory ~/GettingStarted/apache-tomcat-7.0.32. Do you notice anything new?

Tomcat Log Files

Tomcat logs/

1. Look at the different types of log files being generated in the Tomcat logs/ directory.

Move into the logs/ directory to see the type of information being logged:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32/webapps

$ cd ../logs

Page 17: Tomcat Linux

$ ls -l

-rw-r--r-- 1 tds ustaff 10635 Oct 19 18:10 catalina.2012-10-19.log

-rw-r--r-- 1 tds ustaff 10748 Oct 19 18:10 catalina.out

-rw-r--r-- 1 tds ustaff 0 Oct 19 18:02 host-manager.2012-10-19.log

-rw-r--r-- 1 tds ustaff 2820 Oct 19 18:10 localhost.2012-10-19.log

-rw-r--r-- 1 tds ustaff 0 Oct 19 18:02 localhost_access_log.2012-10-19.txt

-rw-r--r-- 1 tds ustaff 0 Oct 19 18:02 manager.2012-10-19.log

Do you see a correspondence between some of the web applications in the Tomcat webapps/ directory and the naming of certain log files?

Is there a difference in the information being logged to catalina.out versus catalina.yyyy-mm-dd.log?

Are some log files more verbose than others?

2. Examining catalina.out.

Open another terminal window (hereafter referred to as terminal #2) and run the following command in the new terminal:

$ tail -f /home/tds/GettingStarted/apache-tomcat-7.0.32/logs/catalina.out

In your original terminal window, start/stop and start Tomcat and watch what is being logged to catalina.out in the terminal #2 window.

Is it only errors messages being reported to catalina.out?

What messages in catalina.out are from the TDS?

Things to know about catalina.out

catalina.out

The Tomcat Users mailing list has seen a lot of traffic dedicated to catalina.out logging and rotation.

Tomcat System.out and System.err gets appended to catalina.out. catalina.out can quickly grow large if the hosted web applications are not specifically

catching and logging System.out and System.err to designated files.

Page 18: Tomcat Linux

catalina.out is not automatically rotated in Tomcat. You should employ an outside log rotation program (e.g., logadm or logrotate) to rotate

catalina.out. It is good practice to archive and remove old catalina.out files and other log files out

of the Tomcat logs/ on a regular basis. On Windows, the catalina.out file is not automatically created. Instead only the

catalina.yyyy-mm-dd.log files are used. These have equivalent content.

Tomcat (Server-Level) Configuration Files

About server.xml

Keep in mind

Tomcat's configuration files, including server.xml can be found in in the Tomcat conf/ directory.

XML file (well-formed syntax is important). Tomcat's main configuration file. Changes to server.xml do not take effect until Tomcat is restarted. Where we make changes to enhance TDS security.

Important elements in server.xml

1. Examine the Elements in server.xml.

Move into the Tomcat conf/ directory and examine the server.xml file:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32/logs

$ cd ../conf

$ less server.xml

Reference the table below to see how the server.xml elements relate to configuring TDS (mouse-over the element for a description):

Tag Name Instances How it relates to the TDS

<Server> 1...1 Not modified unless you want to change the port number Tomcat listens for a SHUTDOWN command. (Enabled by default.)

<GlobalNamingResources> 0...* Needed to contain the UserDatabase that

Page 19: Tomcat Linux

corresponds to the UserDatabaseRealm used to authenticate users. (Enabled by default.)

<Resource> 0...* Editable user database (tomcat-users.xml) used by UserDatabaseRealm to authenticate users. (UserDatabaseRealm Resource enabled by default.)

<Service> 1...* Not modified unless you wish to establish more than one service. (Catalina Service enabled by default.)

<Connector> 1...* Used to establish HTTP and SSL connections. Also will communicate with an web server for proxying requests. (HTTP connector enabled by default on port 8080.)

<Engine> 1...1 Not modified unless you specify a Host other than localhost. (Enabled by default.)

<Realm> 0...* The UserDatabaseRealm uses the UserDatabase configured in the global JNDI Resource. (UserDatabaseRealm enabled by default.)

<Valve> 0...* The RemoteAddrValve is used to filter access to the TDS based on IP address. (NOT enabled by default. You will need to add this if you want to use IP Filtering.)

<Host> 1...* Not modified unless you specify a Host other than localhost. (localhost enabled by default.)

<Realm> 0...* We use the MemoryRealm to configuring Tomcat to use digested passwords. (NOT enabled by default. You will need to add this if you want to use digested passwords.)

<Valve> 0...* We modify the AccessLogValve to customize the access logs generated by Tomcat. (NOT enabled by default. You will need to add this if you want to enable access logging.)

About tomcat-users.xml

XML file (well-formed syntax is important). Stores user names, passwords and roles. Changes to tomcat-users.xml do not take effect until Tomcat is restarted. What the TDS uses for user authentication and access control.

Important elements in tomcat-users.xml

1. Examine the Elements in tomcat-users.xml.

Page 20: Tomcat Linux

Open the tomcat-users.xml file:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32/conf

$ less tomcat-users.xml

Reference the table below to see how the tomcat-users.xml elements relate to configuring TDS (mouse-over the element for a description):

Tag Name Instances How it relates to the TDS

<tomcat-

users> 1...1 Not modified. (The only tag you get by default.)

<role> 1...* You will have at least two of these: one for the Tomcat manager application and one for the TDS. (You will need to add if you want to enable role-based authentication.)

<user> 1...* You will need to create an entry for each user who needs access to the Tomcat manager application and/or the restricted areas of the TDS. (You will need to add if you want to enable user authentication.)

Tomcat manager Application

About the manager application

More about manager

For more information about the Tomcat manager application, see the Tomcat Manager App HOW-TO documentation.

"Free" web application that comes with Tomcat distribution. Lives in the manager directory in the Tomcat webapps/ directory. Allows Tomcat administrators to deploy, undeploy, or reload web applications such as

the TDS without having to shut down and restart Tomcat. Provides server status statistics for the JVM and each connector you have configured in

server.xml.

Accessing the Tomcat manager application

Changes to the manager application

The manager application URLs and roles has been re-structured. See the Tomcat Migration guide for more information.

Page 21: Tomcat Linux

Attempt to access the Tomcat manager application in your browser: http://localhost:8080/manager/html/. You will be prompted to login via BASIC authentication, which will end in failure since we do not yet have permission to access the manager application:

Based on what we know about Tomcat configuration, which file in the Tomcat conf/ directory should we edit to grant ourselves access to the manager application?

Keep in mind

Changes to tomcat-users.xml do not take effect until Tomcat is restarted.

Granting access to the manager application

1. Modify tomcat-users.xml to add role and user elements.

Using your favorite editor, open ${tomcat_home}/conf/tomcat-users.xml:

$ vi tomcat-users.xml

Between the <tomcat-users> tags, add a role element and specify the rolename attribute as manager:

<tomcat-users>

<role rolename="manager-gui"/>

</tomcat-users>

Now add a new user by adding a user element. Create a username and password for the new user and specify manager-gui as one of the roles (in this example we are creating a user called 'admin' with a corresponding password of 'secret'):

<tomcat-users>

Page 22: Tomcat Linux

<role rolename="manager-gui"/>

<user username="admin" password="secret" roles="manager-gui"/>

</tomcat-users>

2. Restart Tomcat and log into the manager application.

Thinking ahead

To gain access to restricted parts of the TDS, you will perform the same steps you used to grant yourself access to the manager application.

Attempt to access the manager application again (http://localhost:8080/manager/html/), this time logging in using the name and password specified in tomcat-users.xml:

Voilà! You should have access to the manager application.

Troubleshooting

o Check the XML syntax in tomcat-users.xml to make sure it is well-formed and without error.

o Did you restart Tomcat after you made your changes to tomcat-users.xml?

o Any errors will be reported in the Tomcat logs/catalina.out file.

Exercise Four: Grant yourself access to the Tomcat manager application

1. Using the steps outlined above, modify tomcat-users.xml to grant yourself access to the Tomcat manager application.

Page 23: Tomcat Linux

Deploying the TDS using the manager application

1. Use the manager application to undeploy the TDS.

Find the TDS in the list of web application on the Applications page. Stop and then Undeploy the TDS:

List the contents of the Tomcat webapps/ directory to verify that both thredds.war and the unpacked thredds/ directory have been removed:

$ pwd

/home/tds/GettingStarted/apache-tomcat-7.0.32/conf

$ cd ../webapps

$ ls -l

drwxr-xr-x 13 tds ustaff 4096 Oct 19 18:00 docs

drwxr-xr-x 6 tds ustaff 4096 Oct 19 18:00 examples

drwxr-xr-x 5 tds ustaff 4096 Oct 19 18:00 host-manager

drwxr-xr-x 5 tds ustaff 4096 Oct 19 18:00 manager

drwxr-xr-x 3 tds ustaff 4096 Oct 19 18:00 ROOT

2. Deploy the TDS using the manager application.

Upload the TDS WAR file using the Deploy section of the manager application:

Page 24: Tomcat Linux

Confirm the deployment went as planned by accessing the TDS using your browser: http://localhost:8080/thredds/

Exercise Five: Deploy the THREDDS Data Server using the manager application

1. Using the steps outlined above, deploy the TDS using the manager application.

Next Steps: Where To Go From Here

You're not finished yet

TDS remote management tool

You will need to enable Enable SSL encryption to access TDS remote management tool.

We highly recommend you follow the best practices outlined in the Tomcat and TDS Security Considerations section of the tutorial to finish hardening your server environment.

The Basic TDS Configuration and TDS Configuration Catalogs sections of this tutorial covers the TDS configuration files, configuration options and TDS catalog structure.

Additional sections of the tutorial cover how to enable OGC/ISO Services, and Using NcML in TDS.

This document is maintained by Unidata. Send comments to THREDDS support.   Last updated: November 2, 2012

TDS Workshop Home Getting Started with Tomcat, Java and the TDS

Contact Us

Terms of Use Privacy Policy Participation Policy

Page 25: Tomcat Linux

The Unidata Program Center is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is funded by the National Science Foundation.