Wednesday, November 19, 2008

Useful notes on tomcat container

Start Up Tomcat

(3.1) Tomcat can be started by executing the following commands:

$CATALINA_HOME\bin\startup.bat (Windows)

$CATALINA_HOME/bin/startup.sh (Unix)

(3.2) After startup, the default web applications included with Tomcat will be
available by visiting:

http://localhost:8080/

(3.3) Further information about configuring and running Tomcat can be found in
the documentation included here, as well as on the Tomcat web site:

http://tomcat.apache.org


(4) Shut Down Tomcat

(4.1) Tomcat can be shut down by executing the following command:

$CATALINA_HOME\bin\shutdown (Windows)

$CATALINA_HOME/bin/shutdown.sh (Unix)


==================================================
Advanced Configuration - Multiple Tomcat Instances
==================================================

In many circumstances, it is desirable to have a single copy of a Tomcat
binary distribution shared among multiple users on the same server. To make
this possible, you can pass a "-Dcatalina.base=$CATALINA_BASE" argument when
executing the startup command (see (2)). In this
"-Dcatalina.base=$CATALINA_BASE" argument, replace $CATALINA_BASE with the
directory that contains the files for your 'personal' Tomcat instance.

When you use this "-Dcatalina.base=$CATALINA_BASE" argument, Tomcat will
calculate all relative references for files in the following directories based
on the value of $CATALINA_BASE instead of $CATALINA_HOME:

* bin - Only setenv.sh (*nix) and setenv.bat (windows)

* conf - Server configuration files (including server.xml)

* logs - Log and output files

* webapps - Automatically loaded web applications

* work - Temporary working directories for web applications

* temp - Directory used by the JVM for temporary files (java.io.tmpdir)

If you do not pass the "-Dcatalina.base=$CATALINA_BASE" argument to the
startup command, $CATALINA_BASE will default to the same value as $CATALINA_HOME,
which means that the same directory is used for all relative path resolutions.


================
Troubleshooting
================

There are only really 3 things likely to go wrong during the stand-alone
Tomcat install:

(1) The most common hiccup is when another web server (or any process for that
matter) has laid claim to port 8080. This is the default HTTP port that
Tomcat attempts to bind to at startup. To change this, open the file:

$CATALINA_HOME/conf/server.xml

and search for '8080'. Change it to a port that isn't in use, and is
greater than 1024, as ports less than or equal to 1024 require superuser
access to bind under UNIX.

Restart Tomcat and you're in business. Be sure that you replace the "8080"
in the URL you're using to access Tomcat. For example, if you change the
port to 1977, you would request the URL http://localhost:1977/ in your browser.

(2) An "out of environment space" error when running the batch files in
Windows 95, 98, or ME operating systems.

Right-click on the STARTUP.BAT and SHUTDOWN.BAT files. Click on
"Properties", then on the "Memory" tab. For the "Initial environment" field,
enter in something like 4096.

After you click apply, Windows will create shortcuts which you can use
to start and stop the container.

Wednesday, November 12, 2008

Troubleshooting virtual memory

Process Virtual Memory

Source:

http://www.princeton.edu/~unix/Solaris/troubleshoot/vm.html

Each process maps either 2^32 or 2^44 bytes of memory (depending on whether the OS is running in 32 or 64-bit mode). This works out to 4GB or 16TB. Not all of this memory is allocated (used); the virtual memory is used as address space that can be mapped to actual memory resources.

Virtual memory structure for a process can be described as in this diagram:

Kernel

While this is part of the address space, it cannot be addressed directly by the process. It must be addressed via system calls.
Stack

Used by the program for variables and storage. It grows and shrinks in size depending on what routines are called and what their stack space requirements are. It is normally about 8MB in size.
Shared Libraries
Shared libraries are position independent so that they can be shared by all programs that want to use them. One common example is libc.so.
hole

This is the address space that is unallocated and unused. It does not tie up physical memory. For most processes, this is the largest portion of the virtual memory for the process.
heap

Used for some types of working storage. It is allocated by the malloc function.
BSS

Uninitialized variables. These are not part of the executable file and their initial value is set to zeros.
Data

Global variables, constants, static variables from the program.
Text

Set of instructions from the compiler-generated executable file.

The virtual memory map for a process can be displayed using the pmap command.

Additional information is available on the Processes page.

Extracting .bz2 or .bzip2 files

To extract the file file.bz2, use

bzip2 -d file.bz2

This will an uncompressed file in the current directory called ‘file’ and will delete the original bz2 archive. If you want to keep the original file, add the -k option like

bzip2 -dk file.bz2

A useful option for bzip2 is the -c switch which causes bzip2 to write the uncompressed output to stdout which can easily be redirected to another option. For instance, to search the compressed file file.bz2 for the string tech-recipes, use:

bzip2 -dc file2.bz2 | grep tech-recipes

source:
http://www.tech-recipes.com/rx/1495/extract-a-bz2-or-bzip2-file/