Friday, October 4, 2013

Understanding virtual host mapping in WebSphere Application Server

Together with the context root, the virtual host assigned to a Web module determines under which URLs that Web module will be accessible. In WebSphere, a virtual host is simply a set of host aliases, where each alias specifies a host name (or a * wildcard to match any host name) and a port number. Configuring virtual hosts is pretty straightforward, but problems may occur if there are multiple virtual host definitions that have overlapping host aliases, i.e. if the same host name/port combination is matched by multiple virtual hosts.
To see why this happens, it is important to understand how virtual host mapping in WebSphere works internally. Each application server maintains a map with the following structure:
{ host alias → { context root → Web module } }
That means that for each host alias, there is a separate map that maps from the context root to the Web module. Entries in these data structures are created (resp. removed) as Web modules are started (resp. stopped). Note that at this point wildcards are not replaced yet.
To illustrate how this works, consider the following sample topology:
  • A WebSphere application cluster with two members running on hosts srv-a.example.org and srv-b.example.org and listening on port 9080.
  • A Web server having two host names web1.example.org and web2.example.org and listening on port 80.
  • Two Web modules module1 (with context root /app1) and module2 (with context root /app2) that are expected to answer requests on host names web1.example.org and web2.example.org respectively.
If one further assumes that module1 and module2 should also accept requests sent directly to srv-a.example.org and srv-b.example.org (i.e. without going through the Web server), then one would define the following virtual hosts:
  • vhost1 with aliases web1.example.org:80 and *:9080.
  • vhost2 with aliases web2.example.org:80 and *:9080.
module1 would be mapped to vhost1 and module2 would be mapped to vhost2. Both cluster members would then build the following map internally:
AliasContext rootWeb module
web1.example.org:80/app1module1
web2.example.org:80/app2module2
*:9080/app1module1
/app2module2
The structure of the map described above implies that mapping a request to a Web module is a two-step process. WebSphere will first match the Hostheader of the incoming request. At this point, wildcards are processed. WebSphere will then use the corresponding { context root → Web module } map to look up the Web module based on the path part of the URL.
In the example shown above, the fact that the same host alias appears in multiple virtual host definition doesn't cause any issue. Any request sent directly to the application servers via port 9080 will be routed correctly to the expected Web module.
Now consider a slightly different virtual host configuration:
  • vhost1 with aliases web1.example.org:80 and *:9080.
  • vhost2 with aliases web2.example.org:80, srv-a.example.org:9080 and srv-b.example.org:9080.
This will result in the following map:
AliasContext rootWeb module
web1.example.org:80/app1module1
web2.example.org:80/app2module2
*:9080/app1module1
srv-a.example.org:9080/app2module2
srv-b.example.org:9080/app2module2
In this case, things will not work as expected. In fact, requests for http://srv-a.example.org:9080/app1/index.html will not be routed tomodule1. As noted earlier, WebSphere will first match the Host header against the host aliases. The value of that header (srv-a.example.org:9080) matches both *:9080 and srv-a.example.org:9080, but WebSphere will select the second one because it is more specific than the alias with the wildcard. WebSphere will then look at the { context root → Web module } map for that alias. The problem is that this map now contains a single entry mapping /app2 to module2, i.e. there is no entry matching /app1/index.html.
The conclusion is that when configuring virtual hosts, a problem will occur if one virtual host has an alias of the form host:port and another one has an alias *:port with the same port number.

Tuesday, September 24, 2013

Useful Unix File Finding Commands

Useful Unix File Finding Commands

Following are some bunch of commands that might be useful if you want to find files in unix/linux.

Large Files

Find files larger than 10MB in the current directory downwards…
find . -size +10000000c -ls
Find files larger than 100MB…
find . -size +100000000c -ls

Old Files

Find files last modified over 30days ago…
find . -type f -mtime 30 -ls
Find files last modified over 365days ago…
find . -type f -mtime 365 -ls
Find files last accessed over 30days ago…
find . -type f -atime 30 -ls
Find files last accessed over 365days ago…
find . -type f -atime 365 -ls

Find Recently Updated Files

There have been instances where a runaway process is seemingly using up any and all space left on a partition. Finding the culprit file is always useful.
If the file is being updated at the current time then we can use find to find files modified in the last day…
find  . -type f -mtime -1 -ls
Better still, if we know a file is being written to now, we can touch a file and ask the find command to list any files updated after the timestamp of that file, which will logically then list the rogue file in question.
touch testfile
find .  -type f -newer testfile -ls

Finding tar Files

A clean up of redundant tar (backup) files, after completing a piece of work say, is sometimes forgotten. Conversely, if tar files are needed, they can be identified and duly compressed (using compress or gzip) if not already done so, to help save space. Either way, the following lists all tar files for review.
find . -type f -name "*.tar" -ls
find . -type f -name "*.tar.Z" -ls

Large Directories

List, in order, the largest sub-directories (units are in Kb)…
du -sk * | sort -n
Sometimes it is useful to then cd into that suspect directory and re-run the du command until the large files are found.

Removing Files using Find

The above find commands can be edited to remove the files found rather than list them. The “-ls” switch can be changed for “-exec rm {}\;”=.
e.g.
find . -type f -mtime 365 -exec rm {} \;
Running the command with the “-ls” switch first, is always prudent to see what will be removed.
The “-ls” switch prints out summary information about the file (like owner and permissions). If just the filename is required then swap “-ls” switch for “-print”.

Wednesday, August 14, 2013

Difference between War, Jar & Ear

Difference between War, Jar & Ear


1.JAR : JAVA Archives and it allows aggregating many files into One.It usually hold java classes in lib.
JAR files (Java ARchive) allows aggregating many files into one, it is usually used to hold Java classes in a library. i.e. Math.jar 
(file with a .jar extension)

2.War(web archive)   This is Web Application archive which contains basic web application like servlet, jsp, html. This can be run on simple tomcat server
WAR files are similar to JAR files, except that they are specifically for web applications made from Servlets, JSPs, and supporting classes(file with a .war extension)


3.Ear (: Enterprise Archives)
An EAR file is an enterprise application deployed to an application server like WebLogic, WebSphere, JBOSS, etc. It might contain WARs, JARs, etc. 

EAR = WAR(Web module) + JAR(can be EJB module or application client module)
files with a .ear extension

Saturday, January 26, 2013

Too many files opened issue

How to solve too many files issue?

This issue occur in two areas
1. If Web server, App server and Data base servers residing in One machine, then you m ayget this error
2. If socket timed out not mentioned then this issue may this issue.

Using ulimit -a command, we will find how many sockets had that machine. In any machine 1024 is the maximum sockets.

Bottleneck identification:

Using netstat -a|grep WAIT|wc -l command we will find how many sockets opened by the application. If 1024 connection are utilized then we will get too many open files.

If you want know which server opened more socket, just use lsof -p <Process ID> for finding the sockets opened by that process.

Internal Process  of a socket: All HTTP requests internally used TCP connection. One TCP connection is one Socket in computer science language. So if you send n number of requests to the server , the server opens the socket to handle your requests but we need to close the sockets once your request got over other wise socket won't close, for this we need to mention the socket timed out.

Solutions:


For issue 1: Just increase the sockets using ulimit -Hn <Parameter> (Ex ulimit -Hn 2048)command, but it is not recommended , you have to discuss with your architect on this.

For issue 2: Just provide the socket time out in your server configuration file. In web server change the value in  uri_worker.property file

Wednesday, August 8, 2012

Websphere application server Admin ND 7.0, Online training


 Websphere application serve 8.5.5 Administration on linux, Online /classroom training
This course provides the student with the necessary skill set to handle all sorts of administrative tasks on WebSphere Application server 8.5.5 ND.However with an instructor we can tremendously speed up the learning process. The following are the topics covered.

Contace details :
Suvash  :9008500244
Mohan  : 9739172531
gsgudi@gmail.com
Course type : Classroom/ online training
Duration: 5 weeks

8.5.5.0 New Features
Architecture 
Websphere application server ND 8.5.5 Architecture 
Need for application servers
WAS management features
WAS flavors
WAS Topologies
Installation
Virtual Box installation
Preparation and prerequisites
Graphical installation
Installation verification/problems during installation
Profiles 
profile types 
Different ways to create a profile
profile Directory structure
Profile Backup /restore
Profile Delete
Node federation
Workload Management (WLM) & High Availability
 
Clustering (vertical & Horizontal)
Virtual Host
start to end of request processing in clustered env
Edge Components
Load Balancer
HA Manager
 
System Management & Application 
Log files
Cell, Dmgr, Node, Profile, Server terminology
Start/Stop Environment
Admin console overview
Deployment of JEE Applications (.war & .ear)
Synchronization of Config file & settings

Deploying your Applications
Application file types
Deploying an application
Starting and stopping your applications
Data access applications
Data sources
Preparing our sample database
JDBC providers
Creating a JDBC provider
Creating a J2C alias
Creating a data source
Deploying a data access application
Selecting installation options
Mapping modules to servers
Providing JSP reloading options for web modules
Mapping shared libraries
Mapping resource references to resources
Mapping virtual hosts for web modules
Mapping context roots for web modules
Reviewing the deployment steps
Using the application
IBM HTTP Server & Plug-in 
Installing IHS and WebSphere Plug-in
Creating Web server definition
Plug-in generation and propagation
Administrative Scripting
The wsadmin tool
Interactive commands
Individual commands
Profile scripts
Command script files
Listing installed applications with Jython
Installing an application using Jython
Querying application status
Security 
Global security
Global security registry types
Turning on global security
Standalone custom registry
Local operating system
Configuring an LDAP registry in WebSphere(LDAP config material)
Administrative roles
Mapping users and groups to administrative roles
Monitoring & Tuning 
Enable Appl Server Performance monitoring
Dynamic Cache
Tivoli Performance Viewer (TPV)
TPV advisor
Request Metrics
JVM tuning
JVM core and heap dumps
Requesting a Java core dump using Jython
Requesting a heap dump using Jython
Requesting a Java core dump using the kill command
JVM-triggered heap dump
Analysing a Java core (thread) dump
Problem Determination & troubleshooting 
where to start
symptoms of a problems
Importance of Log files, trace & analyzer
Heap dump & Thread dump
Hung Thread detection
Memory leaks diagnostics
 
How to send error to IBM
WebSphere Configuration
File structure
XML configuration files
Important properties files
Logs
JVM settings
Classloaders
SSL
SSL Concepts
Configure SSL between IHS and WAS
The ikeyman tool
Product Maintenance
Locating and downloading updates
Update installers
Applying updates
 Verification of updates
 Silent updates
 Feature packs
 Backing up your system
 Installer logs
Interview Stuff 
Sample WAS Resumes
Providing WAS FAQ’s
Certification Dump 
Redbooks
Introducing you to IBM various WAS Resources.....






Thursday, July 28, 2011

To verify if TRACE is enabled/disabled for Apache Webserver

After TRACE has been disabled according to the instructions mentioned in my thread, a TRACE request will be responded to with HTTP status code 403 (FORBIDDEN).

Using telnet to verify the configuration for a non-SSL web server port
The telnet command provided with most operating systems can be used to verify that the configuration changes to disable TRACE have been made. Note that telnet can only be used to test non-SSL ports, since it does not have the capability to perform the SSL handshake or to encrypt the data.

$ telnet 127.0.0.1 8080
Trying...
Connected to 127.0.0.1.
Escape character is '^]'.
TRACE / HTTP/1.0
A: b
C: d
Host: foo

HTTP/1.1 403 Forbidden
Date: Mon, 04 Oct 2004 14:23:31 GMT
Server: IBM_HTTP_SERVER
Connection: close
Content-Type: text/html; charset=iso-8859-1

Forbidden

You don't have permission to access /
on this server.

Connection closed.

The information sent by the client is no longer echoed, and the request fails with HTTP status code 403.

If the response to the TRACE request continues to result in a response with status code 200, verify that the required directives were added to all containers and the main scope of the configuration file, and also verify that the web server has been restarted to activate the updated configuration.

Sticky Bit (-rwsr-xr-x Unix file permission)

Everybody handling a Unix operating system would very well know what chmod 777 means. That the owner, group and the user of the file is given all permissions (Read, Write and Execute on a particular file). This could otherwise be written as “chmod ugo+rwx “. Meaning that you are giving User, Group and Owner of the file, the rights to Read, Write and Execute the file.

Here comes the rws scenario. Best example that is available for this rws is /usr/bin/passwd command (just issue a “ls -l /usr/bin/passwd”) .

Normally, any user is allowed change HIS password. Meaning he can make an entry or change HIS entry in the /etc/passwd file. But he can never be given ‘WRITE’ permissions on the file because he might end up disturbing other person’s password too. Only a ROOT user is allowed permissions on the /etc/passwd file.

This is where the “rws” comes to picture. When we give “rws” permission to the /usr/bin/passwd command, Unix would assume that the command is executed by the ROOT user. (the user doesnt have permissions on the /etc/passwd file but the root user has). Root user (RWS) permissions could be given on a file as chmod 4700 .

arun@arun-desktop:~/Desktop$ chmod 4700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rws—— 1 arun arun 0 2007-01-17 06:48 hi.txt

If you need to act as a group user of a file and not a normal user when executing a particular command (as against the root user) then user “chmod 2700 ”

arun@arun-desktop:~/Desktop$ chmod 2700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx–S— 1 arun arun 0 2007-01-17 06:48 hi.txt

The 4 and 2 in the front of the chmod commands are called as SUID and SGID bits.

What if we put a 1 instead of 4 and 2 (chmod 1700 ).

arun@arun-desktop:~/Desktop$ chmod 1700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx—–T 1 arun arun 0 2007-01-17 06:48 hi.txt

It shows a “T” in the place of “x” for a normal user. This “T” bit is called as the Sticky bit.

“When the sticky bit is turned on for a directory users can have read and/or write permissions for that directory, but they can only remove or rename files that they own. The sticky bit on a file tells the operating system that the file will be executed frequently. Files like this are kept in swap space even when they aren’t being executed. Although this takes up swap space it greatly reduces the time it takes to execute the program. Some programs such as vi have the sticky bit turned on by default on some Unixes.”