Apache Tomcat Tips and Tricks from the Pros



Similar documents
tc Server Webinar Series Deployments

Tomcat Expert Series. Large Scale Deployments

Apache Tomcat Tuning for Production

Tomcat Tuning. Mark Thomas April 2009

Tcat Server User s Guide. Version 6 R2 December 2009

24x7 Scheduler Multi-platform Edition 5.2

SOLR INSTALLATION & CONFIGURATION GUIDE FOR USE IN THE NTER SYSTEM

Simba XMLA Provider for Oracle OLAP 2.0. Linux Administration Guide. Simba Technologies Inc. April 23, 2013

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

Integrating Apache Web Server with Tomcat Application Server

ConcourseSuite 7.0. Installation, Setup, Maintenance, and Upgrade

Using the Adobe Access Server for Protected Streaming

Apache Tomcat & Reverse Proxies

CORISECIO. Quick Installation Guide Open XML Gateway

Scaling Progress OpenEdge Appservers. Syed Irfan Pasha Principal QA Engineer Progress Software

Product Documentation. Pivotal tc Server. Version 3.x. Getting Started with Pivotal tc Server. Rev: Pivotal Software, Inc.

How To Link Tomcat 5 with IIS 6 on Windows 2003 Server using the JK2 ajp13 connector

Apache Tomcat. Load-balancing and Clustering. Mark Thomas, 20 November Pivotal Software, Inc. All rights reserved.

TCH Forecaster Installation Instructions

Installing and Running Tomcat 5.5

JobScheduler Installation by Copying

Apache and Tomcat Clustering Configuration Table of Contents

VERSION 9.02 INSTALLATION GUIDE.

Clustering a Grails Application for Scalability and Availability

2 Downloading Access Manager 3.1 SP4 IR1

Spectrum Spatial Analyst Version 4.0. Installation Guide for Linux. Contents:

STREAMEZZO RICH MEDIA SERVER

Project Management (PM) Cell

This section is intended to provide sample configurations and script examples common to long-term operation of a Jive SBS installation.

Installation, Configuration and Administration Guide

Canto Integration Platform (CIP)

JAMF Software Server Installation Guide for Windows. Version 8.6

Application Servers - BEA WebLogic. Installing the Application Server

New Features... 1 Installation... 3 Upgrade Changes... 3 Fixed Limitations... 4 Known Limitations... 5 Informatica Global Customer Support...

To install and configure SSL support on Tomcat 6, you need to follow these simple steps. For more information, read the rest of this HOW-TO.

Orbix Release Notes

Installation Guide. Release 3.1

Configuring multiple Tomcat instances with a single Apache Load Balancer

EMC Documentum Content Services for SAP Repository Manager

Upgrade: SAP Mobile Platform Server for Windows SAP Mobile Platform 3.0 SP02

MAPI Connector Overview

ZeroTurnaround License Server User Manual 1.4.0

Configuring ActiveVOS Identity Service Using LDAP

Agenda. Tomcat Versions Troubleshooting management Tomcat Connectors HTTP Protocal and Performance Log Tuning JVM Tuning Load balancing Tomcat

Running Multiple Shibboleth IdP Instances on a Single Host

Installation Guide for contineo

Securing your Apache Tomcat installation. Tim Funk November 2009

Polarion Application Lifecycle Management Platform. Installation Guide for Microsoft Windows

TDA - Thread Dump Analyzer

LICENSE4J AUTO LICENSE GENERATION AND ACTIVATION SERVER USER GUIDE

Metalogix SharePoint Backup. Advanced Installation Guide. Publication Date: August 24, 2015

Oracle Fusion Middleware. 1 Oracle Team Productivity Center Server System Requirements. 2 Installing the Oracle Team Productivity Center Server

Offsite Backup. Installation and Upgrade Guide

WhatsUp Gold v16.3 Installation and Configuration Guide

IBM Unica emessage Version 8 Release 6 February 13, Startup and Administrator's Guide

Install guide for Websphere 7.0

The Server.xml File. Containers APPENDIX A. The Server Container

JAMF Software Server Installation and Configuration Guide for Windows. Version 9.3

IUCLID 5 Guidance and Support

Deploying Intellicus Portal on IBM WebSphere

DocuShare Installation Guide

MailEnable Connector for Microsoft Outlook

Oracle Endeca Information Discovery Integrator

TIBCO Spotfire Automation Services 6.5. Installation and Deployment Manual

How To Integrate IIS6 and Apache Tomcat

NGASI Shared-Runtime Manager Administration and User Guide WebAppShowcase DBA NGASI

CatDV Pro Workgroup Serve r

Upgrade Guide. Product Version: Publication Date: 02/11/2015

DEPLOYMENT GUIDE Version 2.1. Deploying F5 with Microsoft SharePoint 2010

In this chapter, we lay the foundation for all our further discussions. We start

Crawl Proxy Installation and Configuration Guide

Oracle Fusion Middleware

WHAT'S NEW AND DIFFERENT ABOUT COLDFUSION 10 ON TOMCAT

McAfee VirusScan Enterprise for Linux Software

DeskNow. Ventia Pty. Ltd. Advanced setup. Version : 3.2 Date : 4 January 2007

i2b2 Installation Guide

Technical Report. HA Set up with GeoServer

Running multiple Tomcat versions on the same host

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

CA SiteMinder Secure Proxy Server

JAMF Software Server Installation and Configuration Guide for OS X. Version 9.2

TIBCO Silver Fabric Continuity User s Guide

Upgrading Your Web Server from ClientBase Browser Version 2.0 or Above to Version 2.1.1

PowerPanel Business Edition USER MANUAL

Outlook Connector Installation & Configuration groupwaresolution.net Hosted MS Exchange Alternative On Linux

ServletExec TM 6.0 Installation Guide. for Microsoft Internet Information Server SunONE Web Server Sun Java System Web Server and Apache HTTP Server

Installation & Configuration - Enterprise, Group and Community Server

WebLogic Server: Installation and Configuration

vsphere Upgrade vsphere 6.0 EN

Ipswitch Client Installation Guide

SIEMENS. Teamcenter Web Application Deployment PLM

JBS-102: Jboss Application Server Administration. Course Length: 4 days

Pacific Application Server for OpenEdge: Getting Started. Progress OpenEdge 11.5 Workshop

McAfee epolicy Orchestrator Software

JAMF Software Server Installation and Configuration Guide for Linux. Version 9.0

Siebel Installation Guide for UNIX. Siebel Innovation Pack 2013 Version 8.1/8.2, Rev. A April 2014

epolicy Orchestrator Log Files

IBM Endpoint Manager Version 9.2. Patch Management for SUSE Linux Enterprise User's Guide

Transcription:

Apache Tomcat Tips and Tricks from the Pros The webinar will begin shortly... Select audio mode (telephone or VOIP) Telephone dial-in: France: +33 (0) 426 460 175 Germany: +49 (0) 895 4998 6652 Netherlands: +31 (0) 708 912 549 United Kingdom: +44 (0) 20 3051 4836 United States: +1 702 824 9512 Access code: 234-077-969 Audio Pin: Shown in your control panel or confirmation e-mail Questions will be addressed at the end of the webinar Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 1

Apache Tomcat Tips and Tricks from the Pros Filip Hanik Mark Thomas November 2008 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

Welcome Use the questions pane to ask any questions We'll answer them at the end Questions needing longer answers we'll put on the SpringSource blog: http://blog.springsource.com/ If you have a problem, ask a question and one of our colleagues will help you A recording will be available from: http://www.springsource.com/webinars Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3

About SpringSource Created, developed and leads the Spring Framework Offers a host of production ready, enterprise grade products Offers full commercial support for Spring and Apache products Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4

About Us Apache Tomcat Committers for 5+ years Apache Software Foundation members Senior Software Engineers and Consultants SpringSource Covalent Division Performance, troubleshooting and security experts Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5

Tomcat versions Tomcat 6.0.x is the latest and greatest 5.5.x bugs and security 4.1.x occasional bugs and security 3.x, 4.0.x, 5.0.x are unsupported 7.x is on the horizon dependent on the Servlet 3.0 specification some discussions on the mailing list some preparatory work under way Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6

Agenda Tomcat for large-scale deployments Tomcat & JVM upgrades (and roll backs) Production settings Building Tomcat Native the APR based native connector Connector selection Virtual hosting Undocumented options Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7

Large scale deployment Folder structure Overview apache-tomcat-6.0.x/ - bin - conf - lib - logs - temp - webapps - work Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8

Large scale deployment Folder structure Overview apache-tomcat-6.0.x/ - bin - used during startup - conf - CATALINA_BASE - lib - CATALINA_HOME - logs - logging.properties - temp - CATALINA_TMPDIR - webapps server.xml (<Host>) - work - server.xml (<Host>) Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9

Large scale deployment Starting Tomcat bin/ startup.(sh bat) shutdown.(sh bat) <start> <stop> catalina.(sh bat) Startup Scripts Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10

Large scale deployment Starting Tomcat catalina.(sh bat) <invokes> <invokes> setclasspath.(sh bat) setenv.(sh bat) JVM Launch Startup Scripts Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11

Large scale deployments Setting custom options setenv.sh - Any custom options here JAVA_HOME JAVA_OPTS CATALINA_OPTS CATALINA_HOME CATALINA_BASE CATALINA_TMPDIR CATALINA_PID Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12

Large scale deployments Setting custom options setenv.sh doesn't ship with Tomcat Upgrading Tomcat Simply copy setenv.sh No need to modify Tomcat scripts, or keep track of changes inside Tomcat scripts Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13

Upgrades / downgrades JVM setenv.sh JAVA_HOME points to 1.5 or 1.6 Easy to switch back and forth No need to modify any Tomcat scripts /usr/local/tomcat/ - apache-tomcat-6.0.16/ - apache-tomcat-6.0.18/ - jdk1.5.0_16/ - jdk1.6.0_10/ Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14

Upgrades / downgrades Tomcat Instance data can be separated out /usr/local/tomcat/ - apache-tomcat-6.0.16/ - apache-tomcat-6.0.18/ - jdk1.5.0_16/ - jdk1.6.0_10/ - tomcat-instance-01 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15

Upgrades / downgrades Tomcat Instance data can be separated out /usr/local/tomcat/ - apache-tomcat-6.0.16/ - apache-tomcat-6.0.18/ - jdk1.5.0_16/ - jdk1.6.0_10/ - tomcat-instance-01/ - bin - conf - logs - webapps - work - temp Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16

Upgrades / downgrades So far setenv.sh CATALINA_HOME=/usr/local/apache-tomcat-6.0.18 CATALINA_BASE=/usr/local/tomcat-instance-01 JAVA_HOME=/usr/local/jdk1.6.0_10 CATALINA_PID=$CATALINA_BASE/logs/tomcat.pid Modify JAVA_HOME to change JVM Modify CATALINA_HOME to change Tomcat Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17

Upgrades / downgrades In production Most important thing during a production upgrade: How to downgrade/roll back if something goes wrong? With Tomcat, that's easy, keep multiple installations With JVM, that's easy, keep multiple installations Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18

Upgrades / downgrades Package managers Using packages, like RPM Considering using packages that install side by side rather than override Overriding would slow down and complicate the roll-back process Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19

Production settings server.xml <Server port="8005" shutdown="shutdown" > Will allow unauthorized shut-down of Tomcat instance Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20

Production settings server.xml <Server port="-1" shutdown="shutdown" > Disables shut-down port Also disables use of shutdown.sh catalina.sh stop Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21

Production settings server.xml <Server port="-1" shutdown="shutdown" > Stop Tomcat 'kill <pid>' Still is graceful shut-down shut-down hook Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22

Production settings Removing applications ROOT replace with your own /examples security best practice /docs security best practice /manager security best practice will disable remote deployment /host-manager security best practice will disable remote host management Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23

Production settings Logging conf/logging.properties.handlers = \ 1catalina.org.apache.juli.FileHandler, \ java.util.logging.consolehandler Causes duplicate logging May fill up catalina.out (no rotation) Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24

Production settings Logging conf/logging.properties.handlers = \ 1catalina.org.apache.juli.FileHandler Only log to file For development, logging to stdout/stderr is sometimes easier to work with Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25

Production settings Rotating catalina.out http://www.cronolog.org - example tool >> "$CATALINA_BASE"/logs/catalina.out 2>&1 & Rotate on a daily basis 2>&1 /bin/cronolog %Y-%m-%d.catalina.out Changes made in catalina.sh Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26

Production settings Access logging Access Logging can be done using a valve Valve logs as soon as the request is done Introspects request and response to generate output <Valve classname="org.apache.catalina.valves.accesslogvalve" pattern="%h %l %u %t %r %s %b" directory="${catalina.base}/logs" prefix="tomcat_access_" suffix=".log" /> Pattern similar to that of httpd http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27

Production settings Global defaults Sharing a connection pool <GlobalNamingResources> <Resource type="javax.sql.datasource" name="sharedpool"/> </GlobalNamingResources> conf/context.xml <Context> <ResourceLink global="sharedpool" name="jdbc/ds"/> </Context> Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28

Production settings Global defaults All global defaults can be configured in conf/context.xml Can be overridden by application conf/web.xml Can be overridden by application Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29

Production settings Templating Use catalina.properties for server.xml substitution variables #server shutdown port in catalina.properties shutdown.port=-1 <Server port="${shutdown.port}"> </Server> Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30

Production settings Deployment methods Tomcat supports several deployment methods <Context> elements in server.xml Auto deploy WAR file Auto deploy directory Auto deploy XML file Remote deployment Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 31

Production settings Deployment methods Tomcat supports several deployment methods Best practice Select one preferred method Mixing methods may cause unwanted behavior Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32

Building Tomcat Native Unpack your OpenSSL source distro./configure prefix=/tomcat/openssl shared -m64 make make test make install Some platforms like 'make install' before make test' Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33

Building Tomcat Native Unpack your APR source distro export CC='gcc -m64'./configure prefix=/tomcat/apr make make install Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34

Building Tomcat Native Unpack your APR Util source distro export CC='gcc -m64'./configure prefix=/tomcat/apr --with-apr=/tomcat/apr make make install Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35

Building Tomcat Native Unpack your tomcat-native.tar.gz distro export CC='gcc -m64'./configure prefix=/tomcat/tcnative -m64 \ --with-apr=/tomcat/apr \ --with-ssl=/tomcat/openssl make make install Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 36

Building Tomcat Native setenv.sh JAVA_OPTS="-Djava.library.path=\ /tomcat/apr:\ /tomcat/openssl:\ /tomcat/tcnative" Remember, if compiled in 64bit (-m64) You must use a 64 bit JVM Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37

Connector selection Requirement Connectors in preference order Stability BIO NIO/APR SSL APR NIO BIO Low concurrency BIO APR NIO High concurrency No Keep-Alive High concurrency Keep-Alive BIO APR NIO APR NIO BIO Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38

Connector selection Why would you use the NIO connector? The Native (APR) connector is unstable on Solaris NIO is a pure Java solution It is easy to switch between NIO and BIO with SSL Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39

Virtual hosting What is it? Multiple host names served by a single Tomcat instance http://bart.foo.com http://homer.foo.com rather than http://www.foo.com/bart http://www.foo.com/homer Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 40

Virtual hosting Host definition Each host requires an entry in server.xml Each host requires their own appbase Default host still required <Engine name="catalina" defaulthost="bart.foo.com"> <Host name="bart.foo.com" appbase="webapps-bart"/> <Host name="homer.foo.com" appbase="webapps-homer"/> </Engine> Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 41

Virtual hosting Context definition Standard rules apply http://tomcat.apache.org/ tomcat-6.0-doc/config/context.html http://bart.foo.com/ is served by the root context for the host bart.foo.com ROOT.xml, ROOT.war, ROOT Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 42

Virtual hosting Common pitfalls DNS not configured overlapping appbase values docbase==appbase Not using ROOT.war Multiple definitions for same WAR/dir Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 43

Undocumented options ExtendedAccessLogValve W3C Extended Log File Format http://www.w3.org/tr/wd-logfile.html http://tomcat.apache.org/ tomcat-6.0-doc/api/org/apache/catalina/ valves/extendedaccesslogvalve.html Enhancements include logging of: Request parameters (helpful for POST) ServletContext attributes HttpServletRequest methods Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 44

Undocumented options Caching Content requiring authentication should not be cached Tomcat sets caching headers to enforce this IE uses a local cache to download files IE downloads the file and then obeys the headers and deletes it from the cache before you have a chance to open it Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 45

Undocumented options Caching Tomcat can be configured to allow private caching recommended allow public caching not recommended <Context... > <Valve classname="...authenticator" securepageswithpragma="false" </Context> <Context... > <Valve classname="...authenticator" disableproxycaching="false" </Context> Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 46

Undocumented options Caching classname depends on the authentication type configured All in package org.apache.catalina.authenticator BasicAuthenticator FormAuthenticator DigestAuthenticator SSLAuthenticator Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 47

Apache Tomcat support Enterprise level commercial support Guaranteed SLA's Guaranteed bug fixes Security notifications and patches Consulting Troubleshooting Training Security, performance and best practices reviews Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 48

Enterprise support options Severity Response Workaround Permanent Correction Platinum Plan Times: 24 x 7 x 365 Method: phone or web Level 1 1 Hour 72 Hours Next Release Level 2 4 Hours 5 Business Days Next Release Level 3 1 Business Day Next Release Next Release Gold Plan Times: 6AM 6PM local time, weekdays, excluding national holidays Method: phone or web Severity Response Workaround Permanent Correction Level 1 4 Hours 72 Hours Next Release Level 2 1 Business Day 5 Business Days Next Release Level 3 2 Business Days Next Release Next Release Silver Plan Times: 6AM 6PM local time, weekdays, excluding national holidays Method: web Severity Response Workaround Permanent Correction Level 1 1 Business Day None Next Release Level 2 2 Business Days None Next Release Level 3 4 Business Days None Next Release Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 49

Thank you for attending Find out more at: http://tomcat.apache.org SpringSource Enterprise support: http://springsource.com/support insidesales@springsource.com +1 800-444-1935 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 50

Questions? Filip Hanik filip.hanik@springsource.com Mark Thomas mark.thomas@springsource.com http://springsource.com Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 51