Search This Blog

Monday, January 31, 2011

IIS7 and tomcat– basic setup

Every now and again I have to setup IIS and tomcat, this usually involves a gap of a year or so, so for my own sanity I have made some notes on how it sits together. Most of the issues involve jumping IIS versions.

I am assuming that the tomcat service is configured correctly, and I will only detail the tomcat to IIS setup.

We must download the ISAPI_rediect.dll ISAPI filter for IIS. ensure you have the correct version for your architecture (x86/x64).

http://apache.mirror.aussiehq.net.au//tomcat/tomcat-connectors/jk/binaries/

Extract the files into a location on the webserver, you will pointing a virtual directory at this location further on.

I love diagrams as it helps me visualise what is going on. So I have drawn a diagram to aid this

image

IIS

To get tomcat and IIS communicating we have to load an isapi filter into IIS that will handle the communications.

In my example I will be applying the isapi filter to a specific website in IIS, however you could if you wish add it at the server level and it will handle all sites within IIS.

First we have to tell IIS to allow the ISAPI filter. This is down at the server level within the ISAPI and CGI Restrictions.

image

Ok so now we go the site we want to allow the ISAPI filter to run on. And go to the ISAPI filters.

image

While still in the website in IIS, we need to add a virtual directory called Jakarta and point it to the path of isapi_redirect.dll.

image

Now click on the virtual directory and go to Handler Mappings,  click “Edit Feature Permissions” and check “execute”

Ok so we have configured IIS. We now have to configure the properties files that are used by the dll.

Now the redirector can utilise the registry or configuration files. I will cover the config files as this allows you to run multiple redirectors with various configs.

Now in the same folder there should be a file called isapi_redirect.properties. This file provides the filter with its initial config.

isapi_redirect.properties
It gives the virtual directory location of the DLL withiin the website.
extension_uri

logfile location and log level
# Full path to the log file for the ISAPI Redirector
log_file=<physical path>\logs\isapi_redirect.log

# Log level (debug, info, warn, error or trace)
log_level=info

And the path to a couple of other properties files

# Full path to the workers.properties file
worker_file=<physical path>\conf\workers.properties.minimal

# Full path to the uriworkermap.properties file
worker_mount_file=<physical path>\conf\uriworkermap.properties
rewrite_rule_file=<physical path>\conf\rewrites.properties

As you can see I have placed the config files into a subfolder conf and the logs in logs folder, but they can exist anyway really.

So the dll uses this initial config file to provide further setup details.

rewrites.properties
I will ignore the rewrites.properties file as I don’t use it, but it basically allows you to rewrite the url.

uriworkermap.properties
This file tells the extension (isapi_redirect.dll) what constitues a valid request to pass to tomcat. In my case I want everything sent to the website

/*=worker1

So the wildcard means send everything to worker1. No whats worker1?

workers.properties.minimal

The worker is the process that actually communicates to the tomcat process. The workers.properties.minimal file contains the setup for the worker processes. I have only one called worker1 and it set up to call tomcat using ajp13 on port 8009 (usual port).

worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

The worker will send the request to tomcat and then handle the response back to IIS.

Once these have all been configured, ensure the tomcat process is running. Restart the website in IIS and everything should work.

I reference these blogs/pages which provide further excellent info.

http://jspors.blogspot.com/2009/01/setting-up-64-bit-tomcat-6-on-iis7.html

http://tomcat.apache.org/connectors-doc/reference/iis.html

http://apache.mirror.aussiehq.net.au//tomcat/tomcat-connectors/jk/binaries/


Share/Bookmark

Thursday, January 27, 2011

windump (the windows version of tcpdump (linux)

I have had to look at some networking issues, and have found a great utility for the windows environment.

Its exactly the same as tcpdump for linux.

http://www.winpcap.org/windump/

However to get this working you will need WinPcap

http://www.winpcap.org/default.htm

Once installed this is a great tool to watch network traffic.

You can specify IP addresses, subnets, ports, interfaces and combinations of. I provide a few examples, but the documentation is great. And as I said its the equivalent of tcpdump, so commands should work the same.

Watch a particular subnet
windump -n net 192.168.11.0 mask 255.255.255.0

Watch a particular IP and port
windump -n host 192.168.1.226 and tcp port 443

Watch two particular IPs
windump -n host 192.168.11.10 or host 192.168.1.226

Watch a two particular IPs on ports 80 and 443
windump -n (host 192.168.11.10 and (tcp port 80 or 443)) or (host 192.168.1.226 and (tcp port 80 or 443))

List interface and numbers. You need the number to specify an interface to listen on.
windump –D

Watch a particular IP on a particular interface.
windump -i 4 -n host 192.168.17.35

To exclude parameters just append with an exclamation

Watch a particular IP and all traffic except on a specific port

windump -n host 192.168.1.226 and tcp port !443


Share/Bookmark

Thursday, January 13, 2011

Running Powershell script from command line

Recently I had to try and schedule some PowerShell scripts. However running the script proved difficult.

Searching the web I found many references indicating the issue was because of spaces in the path of the script. The solution was to use the ampersand .

http://technet.microsoft.com/en-au/library/ee176949.aspx

powershell.exe &'c:\my scripts\test.ps1'

However this did not work. It would just open the PS prompt. In the end I eventually found the solution was this

powershell.exe “&'c:\my scripts\test.ps1'”

Now I believe it works because of the way parameters are split and passed to PowerShell. See this article.
http://poshoholic.com/2007/09/27/invoking-a-powershell-script-from-cmdexe-or-start-run/

Further references.
http://keithhill.spaces.live.com/blog/cns!5A8D2641E0963A97!6058.entry


Share/Bookmark

Wednesday, December 01, 2010

Xen Cloud Platform (XCP), ISOLINUX, Boot CD

This is really just a quick note for myself to remember what I did to allow me to get the XCP 0.5 installation CD to run on my demo machine.

The problem I had was that I was getting a APIC timer error during the boot process, It suggests to boot using the noapic option, however I had no idea how to change that.

Anyway it took me ages, and I won’t bore you with details.

Extract the files from the iso to a folder.

You will find in that folder structure the following folders

\boot\isolinux

In there is a configuration file called isolinux.cfg, this is what we need to edit.

The isolinux config is set to boot with the default label install, so we need to change either the label entry, booting to another set of boot paramters or just change the paramters under the install label. I went with the later.

LABEL install
    KERNEL mboot.c32
    APPEND /boot/xen.gz dom0_mem=752M noapic acpi_skip_timer_override com1=115200,8n1 console=com1,vga --- /boot/vmlinuz xencons=hvc console=hvc0 console=tty0 --- /install.img

The added paramters are in bold. Ok now I saved this file.

Now to rebuild the bootable iso. For this I used mkisofs (on windows you can download cdrtools that contains this and the necessary cygwin dll)

L:\Software\~freeware\Xen>mkisofs -o bootcd.iso -b boot/isolinux/isolinux.bin -c
boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -iso-level 4 -boot-info-
table L:/Software/~freeware/Xen/XCP-base-0.5

My iso was extracted to L:/Software/~freeware/Xen/XCP-base-0.5, so I created a new iso called bootcd.iso.

And that was that, burnt to a cd and then ran on the computer. Now I need to work at wtf I am doing to actually install xcp. Smile


Share/Bookmark

Sunday, November 07, 2010

Fedora 14 and Windows Networking. (Samba/Netbios/smb)

I wanted to be able to browser and connect to my windows network from the fedora machine.  Here are the hoops I went through to get this working in FC14. Below I only detail how to setup samba to allow connectivity and browsing of windows boxes from linux. I do not detail how to setup smb shares on linux box to allow windows servers to connect to linux.

Install samba

I installed samba in the add/remove software gui.

  • “Server and Client software to interoperate with Windows Machines”
  • “Files used by both Samba servers and clients”
  • ”Documentation for the Samba suite”

all for version samba-3.5.6-69.fc14.

Configure Samba. (etc/samba/smb.conf)

Open smb.conf for editing and change/add the following lines

  • workgroup = <your workgroup>
  • netbios name = <the name of you linux box>
  • name resolve order = bcast hosts lmhosts wins

The name resolve order is important, I did not have a wins env and wanted to allow the broadcast method to resolve machine names. Without the bcast entry you will be unable to browse the windows Network. I was getting “Unable to Mount”/”failed to retrieve server list” until this entry was added. What I faound was that I was able to directly enter ip addresses into Nautilus and connect to windows servers, however actual machine names would not resolve.

Configure the firewall (ensure you apply)

  • System\Administration\Firewall
    • Allow the samba services client and server.

WinBind (not needed but mentioned for clarity)

It must be noted here that there is an additional service windbind, that can allow you to integrate into a windows domain and authenticate againt the users in that domain on the linux box. I was only using this within a home env with no PDC so had no need for this. I include here incase you are heading that way, you will need to look into this.

Other utilities I installed

It must also be said I installed a couple of other utilities to help me along the way.

system-config-services 0.99.47-1.fc14
services viewer (actually views daemons), an interface like windows services.


Share/Bookmark

Thursday, November 04, 2010

Config Dell Remote Access (DRAC) via Windows CMD

I recently discovered that you can configure the DRAC from within windows. If you have installed the DELL server administrator.

You can configure from the command line, using the racadm exe.

racadm setniccfg –s <drac ip> <drac subnet mask> <gateway>

racadm setniccfg -s 192.168.x.x 255.255.255.0 192.168.x.x

I had to setup some servers that already had windows installed. Normally I configure the DRAC via the boot menu. As you can see you can do it without rebooting.

Not sure what other items you can configure but hopefully this will point some people in the right direction.

note: the racadm is in the following location (although I believe it is added to the system path so should run from anywhere).

C:\Program Files\Dell\SysMgt\RAC<versionnumber)\


Share/Bookmark

Monday, August 16, 2010

Where has my memory gone? or locating that leak…

A few days ago I had to deal with an ColdFusion server that had stopped server page requests. The server could be contacted and using RDP it could be controlled however any request for a ColdFusion page was met with nothing.

After looking around and finding nothing obvious the CF service was restarted. This solved the problem, however I did notice that the amount of used memory had not reduced fully. The machine itself has Windows 2008 R2 with 32GB of RAM with CF set to take up 20GB, usually on a CF restart the amount of used memory would drop to a couple of gig. However used memory was still at 17Gigs. I started task manager and looked at the running processes, nothing was taking up 17Gigs worth of memory. Where had this memory gone? Then I noticed the non paged pool memory setting, nothing I usually look at but lo and behold it was sitting at around 17Gigs.

So what was this and how do I fix it. To cut a long story short, after some research I eventually established that this type of behaviour was indicative of a memory leak (memory being used by a process/driver but not released).

So while the restart of the CF server had rectified the issue in the short term, with 17Gig still assigned and unusable CF was going to run into the same problem again (and if the leak kept on growing each time CF restarted there would be  less and less time in between each restart).

The machine was rebooted, this gave us back 17Gigs, and of course gave us longer. In the meantime I set about trying to track down the memory leak.

The screen shots below shows the NonPaged pool size (bottom left 3088MB), not with the 17Gig but with 3Gigs (it was sometime after the reboot).image

So how to track down what was causing the memory leak. Now this is when I came across the excellent Mark Russinovich’s Blog entry

http://blogs.technet.com/b/markrussinovich/archive/2009/03/26/3211216.aspx

Mark Russinovich is a god among Windows people, his sysinternals tools are legendary and since joining Microsoft he has kept up this good work.

The article is a good read and I recommend readin it all, but the section we are interested in is Tracking Pool Leaks.

This article led me onto poolmon, it was a pain to get as I had to download the Windows Driver Kit from Microsoft, although I only needed the poolmon tool. Why microsoft don’t allow this to be downloaded seperatly I don’t know. ANyway I downloaded and installed the WDK locally and then copied the poolmon.exe to the offending server.

On running poolmon you get the following

image

Ok, now you can go and read up about all the bits and pieces here, as I am not going to go into (as I don’t fully understand it all). But there are a number of ways to filter and order the list.

Press B to order list by Bytes

Press D to order the list by Diff

Press F to order list by Frees

Press A to order the list by Allocations

Press P to toggle between listing Paged, NonPaged and Paged & Non Paged

OK, now with the above commands I was able to track down my memory leak to a specific driver. I listed only Nonpaged (pressing P a few times) and then ordered by Bytes. Now a memory leak is identified by a lot of Allocation and a free value that doesnot correlate (ie. not a lot of frees compared to allocations, memory is allocated but not freed). As you can see from my list the Tag BLFP stands out instantly, now as I understand your memory leak may or may not be as obvious as this, and if thats the case I believe you need to track figures this is covered in Marks Russinovich’s article above.

Now with the TAG code identified I did a look on the net, as you will see from Mark’s article you can search the system for the offending driver which I was going to do, but thought I would give google a go, and for once I was lucky and stumbled across someone who had gone through the same issue.

The fault lied with the Broadcom Virtual Network Adapter used for teaming the NICs together on A Dell R710. So in the end all I needed to do was to download the updated version of the Broadcom Management Application that would up date this virtual adapter driver.

I hope that makes sense, I have tried to summarise, simplify and explain what I did. I took a shortcut in not tracking down the driver and googling, so you may have to go and do some work here but hopefully this will get some people started.

Update: To get the update for the Virtual Adapter you don’t want to download the physical adapter drivers. You need to download the Broadcom Management Application Installer, this contains the virtual adapter driver. Link below is shortcut to download page (skip past the physical adapter downloads, unless of course you want to update those to.)

http://www.broadcom.com/support/ethernet_nic/netxtremeii.php

Cheers


Share/Bookmark