Archive for category Linux

pvscsi Linux module for vSphere under Debian

I just saw this URL for all you Debian users out there….you both know who you are !!
http://www.virtuallifestyle.nl/2009/06/using-the-vmware-paravirtual-scsi-controller-to-boot-a-debian-vm/

Tags:

Installing WebObjects on RHEL Centos 5.3

Hi,

I like totally ripped most of these instructions from this site, Installing WO 5.3 or WO 5.4 on Linux , so please give your google adsense love clicks to it. Here is how we did it here…..the main differences are in our apache config and our developer wrote a better init.d script…..as quoted by him. NOW READ !!

0. Before you begin you will require:

  • Installed Sun JDK
  • Installed Apache and development header files
  • Add Dag’s rpmfusion repository. Do not enable it though, we will call it when we need it.

1. Get the WebObjects installer from mDimension’s Web site :

wget http://webobjects.mdimension.com/wolips/WOInstaller.jar

2. Install WebObjects 5.4.3 into /opt

sudo java -jar WOInstaller.jar 5.4.3 /opt

3. Create a user to run wotaskd and JavaMonitor (we are going to follow Mac OS X convensions here)

sudo groupadd appserverusr
sudo useradd -g appserverusr appserver

4. Fix permissions

sudo mkdir /var/log/webobjects
sudo chown appserver:appserverusr /var/log/webobjects
sudo chown -R appserver:appserverusr /opt/Local
sudo chown -R appserver:appserverusr /opt/Library
sudo chmod 750 /opt/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor
sudo chmod 750 /opt/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/Resources/SpawnOfWotaskd.sh
sudo chmod 750 /opt/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd

5. Edit .bash_profile for the appserver user and add the NEXT_ROOT environment variable

export NEXT_ROOT=/opt

6. Change to the appserver user and launch wotaskd and JavaMonitor to ensure everything is working

su - appserver
/opt/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd &
/opt/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor -WOPort 56789 &

7. You should now be able to browse to JavaMonitor at:

http://your.host.name:56789/

8. If you have made it this far you can shut down wotaskd and JavaMonitor and add in the scripts to bring them up on boot.

kill `ps aux | awk '/WOPort 56789/ && !/awk/ {print $2}'`
kill `ps aux | awk '/WOPort 1085/ && !/awk/ {print $2}'`

9. Download the attached start-up script and place it in /etc/init.d

10. Instruct the init script to run the script at boot

chkconfig --add webobjects
/etc/init.d/webobjects start

11. Download and unpack the Wonder source required for the apache adaptor

wget http://webobjects.mdimension.com/wonder/Wonder-latest-Source.tar.gz
tar zxvf Wonder-latest-Source.tar.gz
cd Wonder/Utilities/Adaptors

12. Edit the make.config file to set the environment we are building on

# Set the platform you are building on
ADAPTOR_OS = LINUX

13. Build and install the module

make
cd Apache2.2
apxs -i -a -n WebObjects mod_WebObjects.so

14. Add the following configuration to /etc/httpd/conf.d/webobjects.conf

<IfModule mod_WebObjects.c>

# Path to the Document Root of your Webserver,
# it should contain a directory named WebObjects
WebObjectsDocumentRoot /var/www/html

# You can change the 'cgi-bin' part of WebObjectsAlias to whatever you
# prefer (such as Apps), but the 'WebObjects' part is required.
WebObjectsAlias /cgi-bin/WebObjects

# We set a specific allow rule to prevent default restrictions from denying
# access to the module
<Location /cgi-bin/WebObjects>
    Allow from All
</Location>

# Point /WebObjects requests to the installed document root
Alias /WebObjects /var/www/html/WebObjects
<Location /WebObjects>
    Options -Indexes
    Allow from All
</Location>

# Here are the 3 possible configuration modes.
# The apache module uses one of them to get information
# about your deployed applications.
# 1085 is the reserved port on which wotaskd processes listen to by default.

# Host List Configuration
# wotaskd is started automatically on supported platforms,
# so this is the default mode.
# The apache module gets its configuration from the wotaskds
# listed on the configuration line
# For multiple hosts:
# WebObjectsConfig http://<name-of-a-host>:<port-on-a-host>,http://<name-of-another-host>:<port-on-a-host> <interval>
# For localhost:
WebObjectsConfig http://localhost:1085 10

# Multicast Configuration
# The apache module gets its configuration from all wotaskds
# that respond to the multicast call on the subnet
# WebObjectsConfig webobjects://239.128.14.2:1085 10

# File Configuration
# The apache module gets its configuration from one file
# WebObjectsConfig file://<path-to-a-xml-config-file> 10

# To enable public access to the WOAdaptorInfo page, uncomment the following line
WebObjectsAdminUsername public

# To enable the WOAdaptorInfo page with restricted access,
# uncomment the next two lines and set the user and password
# To access the WOAdaptorInfo page with restricted access, use
# a URL like: http://webserver/cgi-bin/WebObjects/WOAdaptorInfo?user+password.
# WebObjectsAdminUsername user
# WebObjectsAdminPassword password

# To change the logging options, read the following comments:
# The option name is "WebObjectsLog" and the first value indicates the path
# of the log file.
# The second value indicates the log level. There are five, in decreasing
# informational order:
#       "Debug",    "Info",    "Warn",    "Error",    "User"
#
# Note: To enable logging, touch '/tmp/logWebObjects'
# as the administrative user (usually root).
#
# The following line is the default:
WebObjectsLog /tmp/WebObjects.log Debug
</IfModule>

15. Copy the static content into the Apache document root

cd /opt/Library/WebObjects/WODocumentRoot
cp -R WebObjects /var/www/html/

all done!

The init.d script

————————————-

#!/bin/bash
#
# chkconfig: 345 90 10
# description: Provides WebObjects services

USER=”appserver”
NEXT_ROOT=”/opt”
WOTASKD_LOG=”/var/log/webobjects/wotaskd.log”
MONITOR_LOG=”/var/log/webobjects/JavaMonitor.log”

export NEXT_ROOT

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network

# Check that networking is up.
[ “${NETWORKING}” = “no” ] && exit 0

start() {
echo -n “Starting wotaskd and Monitor: ”
daemon –user=$USER “$NEXT_ROOT/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd -WOPort 1085 >> $WOTASKD_LOG 2>&1 &”
daemon –user=$USER “$NEXT_ROOT/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor -WOPort 56789 >> $MONITOR_LOG 2>&1 &”
echo
}

stop() {
echo -n “Shutting down wotaskd and Monitor: ”
WOTASKD_PID=`ps aux | awk ‘/WOPort 1085/ && !/awk/ {print $2}’`
kill $WOTASKD_PID
MONITOR_PID=`ps aux | awk ‘/WOPort 56789/ && !/awk/ {print $2}’`
kill $MONITOR_PID
echo
}

# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
status $processname
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $”Usage: $0 {start|stop|status|restart}”
;;
esac

exit $RETVAL

———————————————–

Tags:

Update to pvscsi on Linux

I just had top build a WebObjects VM using CentOS for our Dev team so had a chance to go over my instructions. The good news is that a 2nd hard disk is not necessary which makes the procedure a lot smoother. The instruction then, once you have the VM up and running and VMTools installed is:

# mkinitrd -f –with=pvscsi /boot/initrd-`uname -r` `uname -r`

Shutdown the VM. Go into Edit Settings and change the SCSI controller from LSI to Paravirtual. Save and Power up the VM. You should have success.

For an updated kernel, see my previous post.

Using pvscsi in Linux – Update

Well, after a bit of playing I will have to streamline my last post. But before I get to that, I figured out a way to build the pvscsi module into the latest kernel update BEFORE you have rebooted. (So you are able to reboot into the new kernel without a Kernel Panic).

My lasy example used kernel vmlinuz-2.6.18-128.el5. The lastest kernel update at the time of writing for Centos  5.3 was vmlinuz-2.6.18-128.1.14.el5. Its modules directory is located under /lib/modules/2.6.18-128.1.14.el5.  When the VMWare Tools are installed, it installs the relevant modules in /lib/modules/`uname -r`/misc. Where uname -r is the current running kernel. If we try make a ramdisk for initrd for the new kernel, we will get an error saying the modules are missing….which they are.

So here is my dodgy solution….

Create a misc directory in the new kernel’s module directory.  # mkdir /lib/modules/2.6.18-128.1.14.el5/misc

Copy the pvscsi.o file from the current kernel’s directory to the new one. # cp /lib/modules/2.6.18-128.el5/misc/pvscsi.o /lib/modules/2.6.18-128.1.14.el5/misc

Create a symlink in that directory for the kernel module.

# cd /lib/modules/2.6.18-128.1.14.el5/misc

# ln -s pvscsi.o pvscsi.ko

You should then be able to make the new initrd image with the new kernel. Ceck out the /etc/grub.conf config file to get the vewrsion number of the latest kernel. In my example, you would run:

# mkinitrd -f –with=pvscsi/boot/initrd-2.6.18-128.1.14.el5.img 2.6.18-128.1.14.el5

This should succeed. The -f flag means to overwrite the current file with that name.

Ok, reboot and you should be successful in booting off the new kernel with the pvscsi module. The re-run ‘vmware-config-tools.pl’ as per normal to rebuild the the VMware Tools for this kernel. When it gets to pvscsi, it will ask to overwrite the current version. Select yes. You could remove this module before you run vmware-config-tools.pl. I have not tried that though.

Remember, this is not supported and YOU are responsible for any problem that may occur. I am not. Ok! Good.

It should work fine though.

Tags:

Installing and using pvscsi in Red Hat and CentOS 5.3 under vSphere 4

Well, after reading a few blogs (I hate that word) on using the pvscsi adaptor under Windows 2003 and 2008 and converting the boot drive to use the pvscsi adaptor, I figured one for Linux was overdue. At the time of this post, only RHEL was supported. This also includes CentOS 5.3. So, it took me 10 minutes, but I worked out how to get Linux to boot from the pvscsi adaptor.

The process is this:

  1. Create CentOS 5.3 VM or use an existing one using the default LSI bus adaptor
  2. Install the latest VMTools.
  3. Add a new drive on a new adaptor. (ie Choose the SCSI ID of (SCSI 1:0) )
  4. Boot and format and install the 2nd drive
  5. Shutdown and change the 2nd drive adaptor to pvscsi
  6. Reboot and make sure the 2nd drive comes up. Check the module is loaded.
  7. Grab the module name.
  8. Create a new initrd for the kernel to boot up with including the pvscsi module.
  9. Shutdown, change the 1st Disk adaptor to pvscsi.
  10. Boot successfully, hopefully.
  11. Voila

Ok, here is the long version.

  1. Create your CentOS or Red Hat VM (I used version 5.3 at the time of writing)
  2. Boot into the OS. Install VMware Tools.
  3. Power down.
  4. Add a new Virtual disk in the Settings section. This will be a temporary drive. Give the Virtual disk a Device ID of SCSI (1:0). This ensures that a second scsi controller will also be added. Save the changes.
  5. Go back into Settings and choose the 2nd SCSI Controller that was just added. Change the Type to Paravirtual. Save and Exit.
  6. Boot the VM.
  7. Ensure the VM sees the new disk and the pvscsi module was loaded.
  • Run # fdisk -l to see the disks on the system. You should see /dev/sdb (the new drive)
  • Create and format the new drive
  • # fdisk /dev/sdb
  • ‘n’
  • ‘p’
  • ‘1’
  • Press Enter for the defaults
  • Press Enter for the defaults
  • ‘w’ to write the change

This will create the disk partition, /dev/sdb1. Format it with:

# mkfs.ext3 /dev/sdb1

Mount the new disk. Of course this is unnecessary but does help with testing and making sure stuff works.

If you could not mount the disk, something must have went wrong or my instructions are bad. Let me know.

Ok, but what about the first disk that the OS boots from? This is the think VMware does not support but it can easily be implemented. when the OS boots, grub reads a few settings from /boot/grub/grub.conf. The important things are the kernel and the initrd image. The kernel is self explanatory. The initrd stands for Initial ramdisk. This ramdisk is loaded at boot with a subset of modules required for the kernel to bootstap the system.  (Something like that…don’t quote me…). So, currently, the kernel knows nothing about the pvscsi module as we loaded it after the system was installed. If we changed the 1st SCSI controller to paravirtual, then the system would boot but the bork when it came time to mount the disks as it would not have found any as it had no disk controller…understand.   So how do we tell it about the new paravirtual disk controller?

You add it to the initrd so the kernel can then initialize the paravirtual SCSI controller and see the disk. How do you add the module?  Do the following:

  1. The VM is now up and running and you have successfully added a 2nd disk on the paravirtual controller. You can also see ‘pvscsi’, when you run, ‘# lsmod | grep pvscsi’.
  2. Create the new ramdisk as follows.
  3. Move the current initrd to a backup. (In my example, the kernel is /boot/vmlinuz-2.6.18-128.el5 and the corresponding initrd file is /boot/initrd-2.6.18-128.el5.img) Any new kernel that gets installed will have a corresponding initrd file installed as well and added to /etc/grub.conf.
  4. Rename the existing initrd. # mv /boot/initrd-2.6.18-128.el5.img /boot/initrd-2.6.18-128.el5.img.bak
  5. Make a new initrd with the same name but with the pvscsi module……..

# mkinitrd –with=pvscsi /boot/initrd-`uname -r`.img `uname -r`

That is the tilde sign, not a sigle quote. (`) Where `uname -r` returns the current kernel version, 2.6.18-128.el5.

Once the new initrd is in place and you have confirmed, (# ls -l /boot), shutdown the VM.

  1. Go into the Settings of the VM and change the Adaptor type of the 1st SCSI Controller to Paravirtual.
  2. Save and Exit.
  3. Boot and test.
  4. You should boot successfully. This means you have booted via the new paravirtual scsi controller.
  5. Hurrah

From then, do what you like. shutdown the VM, remove the 2nd disk, or keep the 2nd disk and place it on the first disk controller, the choice is yours. (Do that in the Setting pane by change Virtual ID from SCSI (1:0) to SCSI (0:1)).

Important things to take note of!

This is unsupported by VMware at the moment but works fine and VMotion does work fine as well. Whenever a kernel update gets released, please make sure to rebuild a new initrd image for the new kernel.

This can be a hassle. One way, would be to shutdown the VM, change the disk controller back to LSI Parallel. Boot, re-run vmware-config-tools.pl to update the tools for the new kernel. The re-run the commands above to rebuild the initrd. then power off, change the controller back to paravirtual and reboot. That is the safest way.

Another way is to try build the modules for the new kernel and build a new initrd. I have to work on how to do that so look out for another post.