Wednesday, October 31, 2007

MYSQL REPLICATION

MYSQL REPLICATION CHEAT SHEET


USER REPLICANT CREATION:

Log into Master server as root and issue this sql statement


GRANT REPLICATION SLAVE, REPLICATION CLIENT
ON *.*
TO 'replicant'@'slave_host'
IDENTIFIED BY 'my_pwd';




Log into Slave server as root and issue this sql statement

GRANT REPLICATION SLAVE, REPLICATION CLIENT
ON *.*
TO 'replicant'@'master_host'
IDENTIFIED BY 'my_pwd';


Configuring the Servers

MASTER:


The only changes need to make in my.cnf are

server-id = 1
log-bin = /var/log/mysql/bin.log


SLAVE:


The only changes need to make in my.cnf are

server-id = 2

master-host = mastersite.com
master-port = 3306
master-user = replicant
master-password = my_pwd

log-bin = /var/log/mysql/bin.log
log-bin-index = /var/log/mysql/log-bin.index
log-error = /var/log/mysql/error.log

relay-log = /var/log/mysql/relay.log
relay-log-info-file = /var/log/mysql/relay-log.info
relay-log-index = /var/log/mysql/relay-log.index

Copying Databases and Starting Replication

Master Server:
mysqldump --user=root --password=my_pwd \
--extended-insert --all-databases \
--master-data > /tmp/backup.sql

*Copy the backup.sql file to slave server and follow the
Below commands.

Slave Server:

mysql --user=root --password=my_pwd < /tmp/backup.sql START SLAVE;


Automating Backups


A shell script to take automated backup of Database dump at slave server.


#!/bin/sh date = `date +%Y%m%d`
mysqladmin --user=root --password=my_pwd stop-slave
mysqldump --user=root --password=my_pwd --lock-all-tables --all-databases > /backups/mysql/backup-${date}.sql
mysqladmin --user=root --password=my_pwd start-slave

Friday, June 8, 2007

LINUX COMMANDS HISTORY

Falling down is not defeat. Defeat is when you refuse to get up.

All the best for your all future assignments in your life and happy LINUX.

Any queries related to Linux can send to mailto:shankermcsa@yahoo.com

Trademarks: Red Hat is a registered trademark of Red Hat, Inc. Linux is a registered trademark of Linus Torvalds. All other trademarks are the property of their respective owners.

UNIX History

First version created in Bell Labs - 1969

AT&T licenses source code for low cost

  • Trademarks UNIX name, "UNIX" name closely held
  • Licensees must create new name for their operating systems
  • Many UNIX "flavors" emerge

GNU Project / FSF

GNU Project started in 1984

r Goal: Create a "free" UNIX clone

r By 1990, nearly all required userspace applications created

r gcc, emacs, etc

l Free Software Foundation

r Non-profit organization that manages the GNU project

Linux Origins

l Linus Torvalds

m Finnish college student in 1991

m Created Linux kernel

l Linux kernel + GNU applications = complete, free, UNIX-like OS

Recommended Hardware Specifications

l Pentium Pro or better with 256 MB RAM or

l 64-bit Intel/AMD with 512 MB RAM

l 2-6 GB disk space

l Bootable CD

l Other processor architectures supported

l Itanium 2, IBM Power, IBM Mainframe

Virtual Consoles

l Multiple non-GUI logins are possible through the use of virtual consoles

l There are by default 6 available virtual consoles

l Available through Ctrl-Alt-F[1-6]

l If X is running, it is available as Ctrl-Alt-F7

The Xorg GUI Framework

l Modern, free implementation of X11

l Highly flexible framework for displaying graphical applications and environments

l Completely network-transparent client/server architecture

l System can be configured to present a graphical login screen on Ctrl-Alt-F7

The Xorg Graphical Environments

l Collections of applications that provide a graphical working environment with a consistent look-and-feel

m GNOME - The default desktop environment

m KDE - Environment based on the Qt toolkit

Starting Xorg

l Nothing needed if system boots to a graphical login. Just authenticate.

l If system boots to a virtual console login, Xorg must be started manually

m Run startx to manually start Xorg

Getting Help

Don't try to memorize everything!

Many levels of help

m whatis

m command --help

m man and info

m /usr/share/doc/

m Red Hat documentation

Extended Documentation

l The /usr/share/doc directory

m Subdirectories for most installed packages

m Location of docs that don't fit elsewhere

r Example configuration files

r Html/pdf/ps documentation

r License details

Some Important Directories

The home directories

m /root, /home/username

l The bin directories

m /bin, /usr/bin, /usr/local/bin

m /sbin, /usr/sbin, /usr/local/sbin

l Foreign filesystem mountpoints

m /media and /mnt

l /etc holds system config files

l /tmp holds temporary files

l /boot holds the kernel and bootloader

l /var and /srv hold server data

l /proc and /sys hold system information

l The lib directories hold shared libraries

m /lib, /usr/lib, /usr/local/lib

Absolute and Relative Pathnames

Absolute pathnames begin with a forward slash

l Complete "road map" to file location

l Can be used anytime you wish to specify a file name

Relative pathnames do not begin with a slash

l Specifies location relative to your current working directory

l Can be used as a shorter way to specify a file name

COMMANDS

If OS is not recognizing the SATA HDD

boot: linux all-generic-ide noapic noiapic

After installing the OS go to rescue mode and edit the grub.conf

#vi /etc/grub.conf

Root (hd0,0)

Kernel (vmlinuz-2.6.9-22.EL ro root=LABEL=/ linux all-generic-ide noapic noiapic rhgb quiet

Initrd /initrd-2.6.9.22.EL.img

Basic commands:

#echo $SHELL shows the default SHELL

#cat /etc/shells shows other existing Shells

#vi /etc/login.defs login information file

#chvt to switch to other terminal

#chage -l <username> to see the A/c policies.

#chage <username> to modify A/c policies

#chage -E -1 <username> to make account never expires.

#date --set "-----------"

Present Working Directory

#pwd

Listing Commands:

#ls

#ls -a

#ll

#ls -ld <filename>

#ll <filename>

#ls -al

Creating the Directory and Files

#mkdir <dir>

#mkdir <dir1> <dir1> <dir1>

#mkdir -p d1/d2/d3

Changing Directory

#cd <dir>

Creating a File

#cat > <filename>

Ctrl+d

#touch <filename>

Copy file

#cp <source path> <destination path>

Move and Renaming file

#mv <source path> <destination path>

Deleting file

#rm -rf <filename>

Append an existing file

#cat >> <filename>

Determining File Content

Files can contain many types of data

l Check file type with file before opening to determine appropriate command or application to use

l file [options] <filename>...

User & Group Admin

Authentication information is stored in plain text files:

o /etc/passwd

o /etc/shadow

o /etc/group

o /etc/gshadow

Changing Your Identity

To change your password, run passwd

m Insecure passwords are rejected

To start a new shell as a different user:

o su

o su -

o su username

o su - username

User Information Commands

Find out who you are

m whoami

Find out what groups you belong to

m groups, id

Find out who is logged in

m users, who, w

Login/reboot history

m last

Syntax:

#useradd <username> to create user

#groupadd <groupname> to create group

#useradd -u <uid> <username>

#groupadd -g <gid> <groupname>

#userdel <username> to delete user

#userdel -r <username> to delete user including home dir.

#passwd <username> to assign passwd

#passwd -S <username> shows passwd set to user or not

#passwd -d <username> to remove passwd

#id <username>

#finger <username>

Syntax: useradd <option> <username>

#usermod -G <groupname> <username>

#usermod -u <uid> <username>

#usermod -d <dir> <username> to change home directory

#usermod -s /bin/ksh <username> to change default Shell

#usermod -c "admin" <username> to put comments

#usermod -u <uid> -o <username> to change UID

#usermod -g <gid> <groupname> to change GID

#usermod -l <newusername> <oldusername> to rename user

#groupmod -n <newgroup name> <oldgroup name> to rename group

#gpasswd -a <username> <groupname> to add members of group

#gpasswd -M <username>,<username> <groupname>

#chown <new owner>.<new group> <file/dir name>

#chgrp <new group name> <file name>

#vi /etc/passwd (backup file: /etc/passwd-)

#vi /etc/group (backup file: /etc/group-)

#vi /etc/shadow (backup file: /etc/shadow-)

#tail <filename>

#head <filename>

Links

#ln <source file path> <destination file path> Hard Link

#ln -s <source file path> <destination file path> Soft Link

Permission of a File

Symbolic Notation: Read=r, Write=w and execute=x

Numeric Notation: Read =4, Write=2 and Execute=1

r w x (Where 1 = on and 0 = off)

1 0 0 =4

0 1 0 =2

0 0 1 =1

UMASK: Universal Mask is a value which is subtracted from the full permissions to generate the default permissions.

Root User Normal User

The full permission of a File is 666 The full permission of a File is 666

-rw- rw- rw- 666 -rw- rw- rw- 666

-rw- r- - r- - 644 -rw- r- - r- - 664

-------------------------------- -------------------------------

-w- -w- 022 (umask) -w- -w- 002 (umask)

The full permission of a Directory is 777 The full permission of a Directory is 777

-rwx rwx rwx 777 -rwx rwx rwx 777

-rwx r- x r- x 755 -rwx r- x r- x 775

-------------------------------- --------------------------------

-w- -w- 022 (umask) -w- -w- 002 (umask)

Syntax:

#umask to see the umask value

#vi /etc/bashrc to change umask value permanently

#chmod <numeric permission> <file/dir>

e.g. #chmod 777 <file/dir>

Special Permissions
SUID Value is 4
SGID
Value is 2

  • Normally, files created in a directory belong to the default group of the user
  • When a file is created in a directory with the setgid bit set, it belongs to the same group as the directory

Sticky Bit Value is 1
Normally, users with write permissions to a directory can delete any file in that

directory regardless of that file's permissions or ownership

With the sticky bit set on a directory, only the owner of a file can delete the file

Example: /tmp

drwxrwxrwt 12 root root 4096 Nov 2 15:44 tmp

ACL
#mount -o remount,acl <mount point> enable the partition with ACL properties

#setfacl -m u:<uname>:<permission> <filename> applying acl to the user level

#setfacl -x u:<uname>:<permission> <filename> to remove the acl

#setfacl -m g:<gname>:<permission> <filename> applying acl to the group level

#getfacl <filename> to check the acl permission

Note: when applying ACL present working directorie must be acl directorie and to make it permanent write inside /etc/fstab

Attribute

#chattr +i <filename>

#chattr -i <filename>

#chattr +a <filename>

#chattr -a <filename>

#lsattr <filename>


Special Users
SUDO

#useradd admin
#passwd admin
#vi /etc/sudoers or #visudo put the admin user in sudo file.
#sudo su - to get the root privileges as a sudo user.

#grep sudo /var/log/secure

Network User
Usr Profiles
#vi /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=2008-01-01
SHELL=/bin/bash
SKEL=/etc/skel (user profiles)

System Initialization

Boot Sequence Overview

  • BIOS initialization
  • Boot loader
  • Kernel initialization
  • init starts and enters the desired runlevel by executing:
    • /etc/rc.d/rc.sysinit
    • /etc/rc.d/rc and /etc/rc.d/rc?.d/
    • /etc/rc.d/rc.local
    • X Display Manager (if appropriate)

BIOS Initialization

§ Peripherals detected

§ Boot device selected

§ First sector of boot device read and executed

Boot Loader Components

  • Boot loader
    • First stage - small, resides in the MBR or a boot sector
    • Second stage - loaded from a boot partition
  • Minimum specifications for Linux:
    • Label, kernel location, OS root filesystem and location of the initial RAM disk (initrd)
  • Minimum specifications for other operating systems:
    • Boot device, label

GRUB and grub.conf

  • GRUB "the GRand Unified Bootloader"
    • Command-line interface available at boot prompt
    • Boot from ext2/ext3, ReiserFS, JFS, FAT, minix, or FFS file systems
    • Supports MD5 password protection
  • /boot/grub/grub.conf
  • Changes to grub.conf take effect immediately
  • If MBR on /dev/hda is corrupted, reinstall the first stage bootloader with:
    • /sbin/grub-install /dev/hda

Starting the Boot Process: GRUB

  • Image selection
    • Select with space followed by up/down arrows on the boot splash screen
  • Argument passing
    • Change an existing stanza in menu editing mode
    • Issue boot commands interactively on the GRUB command line

The Chicken/Egg Module Problem and the Initial RAM Disk

To mount the root filesystem, the kernel typically needs to load modules

o Examples: ext3, jbd, raid1, scsi_mod

An initial RAM disk provides modules

o Compressed cpio archive containing modules, other material

o Created at install time

o Specific to a particular hardware and software platform

Made available to the kernel by GRUB

Use mkinitrd to rebuild

o Example:

o mkinitrd /boot/initrd-$(uname -r).img $(uname -r)

Kernel Initialization

  • Kernel boot time functions
    • Device detection
    • Device driver initialization
    • Mounts root filesystem read only
    • Loads initial process (init)

init Initialization

  • init reads its config: /etc/inittab
    • initial run level
    • system initialization scripts
    • run level specific script directories
    • trap certain key sequences
    • define UPS power fail / restore scripts
    • spawn gettys on virtual consoles
    • initialize X in run level 5

Run Levels

§ init defines run levels 0-6, S, emergency

§ The run level is selected by either

· the default in /etc/inittab at boot

· passing an argument from the boot loader

· using the command init new_runlevel

§ Show current and previous run levels

        • /sbin/runlevel

/etc/rc.d/rc.sysinit

§ Important tasks include:

§ Activate udev and selinux

§ Sets kernel parameters in /etc/sysctl.conf

§ Sets the system clock

§ Loads keymaps

§ Enables swap partitions

§ Sets hostname

§ Root filesystem check and remount

§ Activate RAID and LVM devices

§ Enable disk quotas

§ Check and mount other filesystems

§ Cleans up stale locks and PID files

/etc/rc.d/rc

  • Initializes the default run level per the /etc/inittab file's initdefault line such that:
  • id:3:initdefault:
      • l0:0:wait:/etc/rc.d/rc 0
      • l1:1:wait:/etc/rc.d/rc 1
      • l2:2:wait:/etc/rc.d/rc 2
      • l3:3:wait:/etc/rc.d/rc 3 (default)
      • l4:4:wait:/etc/rc.d/rc 4
      • l5:5:wait:/etc/rc.d/rc 5
      • l6:6:wait:/etc/rc.d/rc 6

Daemon Processes

·A daemon process is a program that is run in the background, providing some system service

·Two types of daemons:

o standalone

o Transient - controlled by the "super-daemon" xinetd

System V run levels

· Run level defines which services to start

o Each run level has a corresponding directory:

Monday, May 28, 2007

How-To: Image Windows XP with Ghost and Sysprep

How-To: Image Windows XP with Ghost and Sysprep


I tend to install and reinstall operating systems quite frequently on my home system. With my hectic schedule, I don’t have time to sit down to reinstall and configure every last program. Although it is arguably easier to use a backup of my system for day-to-day mishaps, I tend to change out peripherals a lot and restoring a system that does not have certain drivers “cleaned out” tends to wreak havoc on a new configuration. To make this process go a bit faster, two years ago I created a “Ghost Image” of my hard drive after doing a basic install. Now, instead of it taking a few hours of toiling away to reinstall a system, I can do this all in about 15 minutes with only half a dozen quick mouse clicks. The trick is to use Norton Ghost or any other imaging software and Microsoft Sysprep.

Part 1: Install XP and Sysprep

  1. Install Windows XP on a clean hard drive.
  2. Do not install any drivers or other utilities that are hardware specific beyond what Windows itself installs.
    • This is necessary to make sure the image is as portable as possible across different types of systems. However, different storage controllers and different HALs (Hardware Abstraction Layers) make this harder to predict.
    • Most modern computers these days work fine with a standard ACPI HAL, but if this image is to be truly portable across multiple machines then it must be determined which specific HAL will be needed. Refer to Microsoft KB309283 if you are completely lost.
    • It is also important to determine if the target system uses a storage controller that normally requires a driver disc during a regular XP install. If this is the case, then the necessary paths to the drivers must be included in the Sysprep.inf file. These must be added to the [SysprepMassStorage] section in the form PCI\VEN_###&DEV_#### = PATH_TO_DRIVER_ON_IMAGED_DRIVE where VEN_#### should be replaced by the Vendor ID number (i.e. VEN_1234) and the DEV_#### should be replaced by the Device ID number (DEV_1234). This information can usually be found in the specifc driver INF files. Here is an example for adding the VMWare SCSI controller driver to sysprep.inf

[SysprepMassStorage]
….snipped out windows mass storage driver list….

PCI\VEN_104B&DEV_1040=C:\Drivers\Mass\VMWare\vmscsi.inf

  1. Create a testuser account with administrative privileges. Use this account to install and configure all the software and policies on the system.
  2. Remember to run Windows Update, Office Update and make sure all the rest of the software is up to date. You’ll probably end up rebooting a few times in between but keep going until everything is updated.
  3. Copy all the start menu items from the testuser account to the Administrator start menu. (Note: This is necessary as some installers do not create start menu items in All Users but within the testuser profile only. This leaves some items missing on the Administrator start menu.)
  4. Log out and log back in as the computer Administrator and then copy the testuser profile folder to the default user profile folder. This is done via Control Panel -> System -> Advanced -> User Profile “Settings” then select testuser and click Copy to. Copy all of this to c:\Documents and Settings\Default User. If you don’t understand then refer to Microsoft KB291586.
  5. Delete the testuser account. Make sure that c:\Documents and Settings\testuser has been deleted too.
  6. Download Sysprep for XP SP2.
  7. Extract the files to c:\sysprep.
  8. Create the basic sysprep.inf file by running setupmgr.exe. This a tool Microsoft provides for creating an answer file so the restore doesn’t involving asking the normal setup questions. The basic steps are below:
    • Run setupmgr.exe
    • Click Create New
    • Click Sysprep Setup
    • Then choose whichever product you are using. In our example it would be XP Professional.
    • The next question asks: Do you want to fully automate the install? All this question determines is who is going to accept the EULA, you or the person restoring the image. Also, picking yes means that you must enter your Product Key. I pick no because this is for my own use and I don’t want someone to swipe my Product Key accidentally, but a large company or OEM may choose differently.
    • The next few sets of options are for you to enter in any information like your Name, Organization, Time Zone, Product Key (I leave this blank), Network Settings, etc.
    • I leave the Computer Name option set to Automatically generate computer name.
    • Once completed, a dialog box will ask where you want to save the file. c:\sysprep\sysprep.inf is the path we’re using in this example.
    • On the completion screen, click Cancel to close setupmgr.exe.

The process of creating a basic sysprep.inf file is now completed.

  1. Before proceeding to the next step, create a custom hardware drivers directory for any drivers needed for the target system. Usually I use c:\drivers.
  2. Open c:\sysprep\sysprep.inf in Notepad and add the following lines to the relavent sections (if the heading doesn’t exist, create it):

[Unattended]
DriverSigningPolicy=Ignore
UpdateInstalledDrivers=Yes
OemPNPDriversPath=drivers\hardware_cat\driver_dir\driver_inf;(repeat);

[SysPrep]
BuildMassStorageSection=Yes

[SysprepMassStorage]

  1. Do not close the sysprep.inf yet! OemPNPDriversPath points to the c:\drivers directory created earlier. For organizational purposes, I split up my custom driver files based on category (i.e. hardware_cat in the example above). For example, all video drivers go under c:\drivers\video and network drivers under c:\drivers\network. In each of those directories, the specific driver bundles are placed with their driver inf files (i.e. driver_dir). For example, the latest nVidia drivers would go into c:\drivers\video\nVidia\. The last part is refering to driver_inf is just that, the name of the inf file. For example, for the latest nVidia driver, the path would be c:\drivers\video\nVidia\nv4_disp.inf. In sysprep.inf, the path would be written as OemPNPDriversPath=drivers\video\nVidia\nv4_disp.inf;. Do not forget the semi-colon as a separator. For the next driver, repeat the procedure by placing the path after the semi-colon without leaving a space. Once all the drivers are added, save the file.
  2. Run c:\sysprep\sysprep -bmsd. This will build the Windows XP standard mass storage drivers section.
  3. While editing sysprep.inf there is an option labeled InstallFilesPath which usually points to c:\sysprep\i386. I usually copy the contents of my XP CD’s i386 directory into c:\sysprep\i386. This isn’t necessary.
  4. Add any custom Storage dirvers to the [SysprepMassStorage] section as detailed above.
  5. Now run C:\sysprep\sysprep.exe.
  6. Pick options Mini Setup and Detect non-plug and play hardware. If you don’t have a volume license and plan on just using this image for restoring the computer the image was made on, then pick the option Don’t regenerate security identifiers. If you have a volume license key and will be using this image for multiple machines then leave that option unchecked. Ensure that Shutdown is selected from the Shutdown mode drop-down menu and click Reseal.
  7. If you left the SID option to regenerate, then a pop-up will ask you to confirm. hit OK to continue.
  8. This will take a while and your system will shut down once the process is complete.

Sysprep is now complete. Part 2 contains instructions on imaging the partition.

Part 2: Norton Ghost Instructions

I’m using an older version of Ghost because the newer versions are trumped by Acronis True Image in terms of having less bugs and more features. However, DOS based Ghost has worked fine for me for most systems. If Ghost fails on your system for some reason, try imaging with Acronis True Image trial version. The basic idea is boot off a floopy or CD on the source system, start the backup program, backup the entire drive as an image file onto some other device (portable hard drive or another drive in the system) and then restoring (as necessary) from that image file onto a target system.

The basic Ghost process is as follows:

Note: You must do this on another machine that has Ghost installed. If you boot the Sysprep machine accidentally then you must go through the entire Sysprep checklist again. Trust me, I learned the hard way more than once.

  1. A Ghost bootdisk must be created for the target system. In Ghost 2003, start Ghost from the Start Menu -> Programs -> Norton Ghost.
  2. Click Ghost Utilities then click Norton Ghost Boot Wizard.
  3. A wizard comes up. Since I plan on saving my image to a portable USB or Firewire hard drive I pick Standard Ghost Boot Disk. You may have to choose another option if you plan on saving the image to a network Ghost image server.
  4. On the next screen, under External Storage Options click the check boxes for USB 2.0 Support or Firewire Support depending on your target backup device. If you are using an internal secondary hard drive, then you don’t need to pick anything.
  5. On the next screen, click Use PC-DOS.
  6. The next screen asks for the path of ghost.exe. The default path is usually fine.
  7. Finally we are presented with a screen asking for the floppy disk drive letter and formating options. Pick the proper drive letter and leave the format options alone. Click next.
  8. This is the Review screen. Make sure all the options are correct and insert an empty floppy into your drive. A format dialog will pop up with a warning that everything on the floppy will be erased. Hit Okay. Close it once it is completed. Ghost will copy the files over.
  9. If you are using an external hard drive then make sure it is connected to the source machine prior to booting the Ghost floppy on the system. If you are using an internal hard drive (not the same one as the Sysprep’d drive) in the source system then make sure there is enough free space on it. Again, you cannot save the image onto the drive/partition you are imaging for obvious reasons.
  10. Put your shiny new floppy into the Sysprep prepared machine and boot off of it.
  11. Create the image following the on-screen directions.
    1. Click Local.
    2. Click Disk. I’ve assumed that we are imaging a single large NTFS partition encompassing the entire drive throughout this tutorial hence the need for either an external drive or different internal hard drive. This can all be done on a single drive with two paritions but I’ll leave for the end user to explore.
    3. Click To Image. The next screen states Select local source drive by clicking on the drive number. Make sure you select the drive that contains the Sysprep prepared XP deployment! Check and double check this. Click Ok.
    4. The next screen reads File name to copy image to. From the drop-down box pick either the external hard drive or internal drive (different from source drive) and then type a short name in the file name box.
    5. The next screen will ask compression options. I usually pick High.
    6. Ghost will image the drive on its own and alert you when it is done.
  12. If you are sure the image was created successfully, you can now move the image onto a burnable DVD, network share, leave it on the portable or secondary hard drive and restore it as necessary. If there was a problem during the imaging process, then do not boot the source system. Just reimage it after addressing whatever caused the image process to fail.

The steps above are a very quick summary so I recommend that anyone truly interested in doing this to head over to Vernalex’s site for an in-depth Sysprep Guide. Along with a lot more detail of the entire process, he has various tools to make everything a little easier. The best utility on his site has to be the Sysprep Driver Sanner tool. It makes the process of adding hardware drivers much easier than the manual process above. Instructions on using it are on his site.

This completes the imaging process. Part 3 includes miscellaneous notes.

Update (2.24.2006): I’ve gotten some great tips from both the comments at Digg and below. Let me address a few of those.

  • Once Sysprep shuts down the computer, if you are able hook up the drive to another system as a secondary device then delete pagefile.sys and hibernat.sys to save a few hundred megs of space in the final image. Thanks master_of_fm.
  • I forgot to go in-depth on the Ghost process. I’ve included basic steps for Ghost 2003 but once the intial Sysprep deployment is made, any disk imaging program can be used. The basic priciples are the same but let me know if you have problems. Thanks hakujin & definiteform.
  • billyboobs34 asked if it is possible to make an image that is totally hardware independant. The quick answer (to be best of my knowledge) is no. The problem hinges on the HAL (Hardware Abstraction Layer) in Windows XP being different on, for example, a uniprocessor and multiprocessor system. The Microsoft Knowledge Base article is linked above. If the HAL is not the problem then it sounds like there may be more of an issue of finding appropriate chipset and mass storage controller drivers for different motherboards. In the custom drivers section, adding in paths to the necessary drivers for other motherboards may mitigate this problem.

In my opinion, the best solution is to have one basic machine for each HAL to make all of your images from. Follow all the steps above but do not reseal the system. Drop down to Ghost (or whatever backup utility you are using) and create an image of the system. In the future, creating compatible images for newer machines would be as simple is restoring the almost-complete Sysprep image and adding in new drivers for the chipset, mass storage controller and anything else you need. Then resealing the system and imaging it for a viable deployment image. Again, I am not an expert so hopefully the Sysprep gurus can step in to address this one if I went wrong somewhere.

  • If you are presented a blue screen of death after restoring the Sysprep image to a target machine, then chances are that either the HAL is incompatible for the target machine, you forgot to build the mass storage driver section or you forgot to add a third-party mass storage driver. Refer to Microsoft KB309283 to confirm the source machine HAL is compatible with the target machine. Refer to Microsoft KB303786 if a Stop 0×7b blue screen is shown. This means that the mass storage driver section or third-party mass storage driver is missing.

Update (3.8.2006): If after rebooting, the install hangs at mup.sys or agp440.sys then it’s more than likely a HAL problem. Refer to the previous update to change your HAL. For most modern day single-processor machines make sure your HAL is changed from Uniprocessor ACPI to Advanced Configuration and Power Interface (ACPI) PC. You can find this setting in Control Panel -> System -> Hardware tab -> Device Manager -> click (+) next Computer -> right click the HAL shown and pick Update Driver -> Install from a list or specific location (Advanced) -> Don’t search. I will choose the driver to install. -> then pick the proper HAL -> hit next/okay until you finish. Now reboot and run through the Sysprep instructions again.

It took me a few tries to finally make an image that restored properly when I first started but, like riding a bike, it’s second nature now. Be ready to experience frustration but in the end it is worth having this knowledge. Again, read the comments below and at Digg to see how others have achieved this process. I don’t claim to be an expert (I’m just a med student by day) but I certainly hope this helps someone.

Friday, March 2, 2007

TOMCAT INSTALLATION AND CONFIGURATION

Introduction

Apache Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process.

Packages required

Java 2 SDK, Standard Edition v1.4.1-01 http://www.blackdown.org/java-linux/java-linux-d2.html

Ant 1.6.5 http://ant.apache.org/

JavaBeans Activation Framework http://java.sun.com/products/javabeans/glasgow/jaf.html

Javamail http://java.sun.com/products/javamail/

jakarta-tomcat-5.X http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi

Installing Java 2 SDK

Untar/unzip j2sdk package

$cp j2sdk1.4.1 /usr/local/

$ln –s j2sdk1.4.1 j2sdk

set JAVA_HOME

$export JAVA_HOME=/usr/local/j2sdk

add PATH for java binary

$export PATH=$PATH:$JAVA_HOME/bin

verify javac command gives some output

root@tux:~# javac

Usage: javac

where possible options include:

-g Generate all debugging info

-g:none Generate no debugging info

-g:{lines,vars,source} Generate only some debugging info

Installing ANT

Untar ant-.tar.gz by

$tar xvzf ant-.tar.gz

move untared directory this to /usr/local/ant

$mv ant- /usr/local/ant

set ANT_HOME

export ANT_HOME=/usr/local/ant

add PATH for ant binary

export PATH=$PATH:$ANT_HOME/bin

verify ant binary is on PATH

root@tux:~# ant

Buildfile: build.xml does not exist! (don’t worry about this message, this was just to check ant in on path or not)

Installing JavaBeans Activation Framework

$unzip jaf-.zip

$cd jaf-

copy activation.jar to /usr/local/j2sdk/lib

$cp activation.jar /usr/local/j2sdk/lib

set CLASSPATH for this jar

$export $CLASSPATH=/usr/local/j2sdk/lib/activation.jar

Installing Javamail

$unzip javamail-.zip

$cd javamail-

copy mail.jar to /usr/local/j2sdk/lib

$cp mail.jar /usr/local/j2sdk/lib

set CLASSPATH for this jar

export $CLASSPATH=$CLASSPATH:/usr/local/j2sdk/lib/mail.jar

All set for tomcat

Just again verify all environment variables

$echo $JAVA_HOME

$echo $ANT_HOME

$echo $PATH

$echo $CLASSPATH

now we have two options to install tomcat

1. using source

2. using binary

Tomcat Installation from source

Untar source

$tar xvzf jakarta-tomcat-5.x.x-src.tar.gz

$cd jakarta-tomcat-5.x.x

start building source

this build process is controlled by build.properties

add this content to it:
# ----- Proxy setup -----
# Uncomment if using a proxy server.
#proxy.host=proxy.domain
#proxy.port=8080
#proxy.use=on

# ----- Default Base Path for Dependent Packages -----
# Replace this path with the directory path where
# dependencies binaries should be downloaded.
base.path=/usr/share/java

$ant build

Buildfile: build.xml

check.source:

check.source.depends:

once this is done without any errors, copy build to appropriate location

$cp jakarta-tomcat-5.x.x/jakarta-tomcat-5/build /usr/local/tomcat

Installation done from source

Tomcat Installation from binary

Download and untar jakarta-tomcat-5.x.x.tar.gz

$tar xvzf jakarta-tomcat-5.x.x.tar.gz

move untared directory to /usr/local/tomcat

$mv jakarta-tomcat-5.x.x /usr/local/tomcat/

Installation done using binary.

Configuring Tomcat

Optionally set CATALINA_HOME to /usr/local/tomcat/

$export $CATALINA_HOME=/usr/local/tomcat/

make changes in configuration, go to conf dir

$cd /usr/local/tomcat/conf

to change port of tomcat edit server.xml Connector port="8080" tag

you can add various roles and assign these roles to different users by making changes in tomcat-users.xml

rolename="tomcat"/>

rolename="role1"/>

rolename="manager"/>

rolename="admin"/>

admin,manager"/>

you can write a init script for tomcat startup/shutdown

#!/bin/sh

export JAVA_HOME=/usr/local/j2sdk

export PATH=$PATH:/usr/local/j2sdk/bin/

case "$1" in

start)

echo -n "Starting tomcat: "

/usr/local/tomcat/bin/startup.sh

;;

stop)

echo -n "Shutting down tomcat: "

/usr/local/tomcat/bin/shutdown.sh

;;

*)

echo "Usage: $0 {start|stop}"

exit 1

esac

exit 0

copy this content to /etc/init.d/tomcat.server

give execute permission

chmod +x /etc/init.d/tomcat.server

on debian do

$update-rc.d tomcat.server defaults

Testing setup

Start tomcat

root@tux:~# /etc/init.d/tomcat.server start

Starting tomcat: Using CATALINA_BASE: /usr/local/tomcat

Using CATALINA_HOME: /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JAVA_HOME: /usr/local/jdk

Check in process list for successful startup

1834 pts/6 S 0:15 /usr/local/jdk/bin/java -Djava.endorsed.dirs=/usr/local/tomcat/common/endorsed -classpath /usr/loc

1835 pts/6 S 0:00 /usr/local/jdk/bin/java -Djava.endorsed.dirs=/usr/local/tomcat/common/endorsed -classpath /usr/loc

1836 pts/6 S 0:01 /usr/local/jdk/bin/java -Djava.endorsed.dirs=/usr/local/tomcat/common/endorsed -classpath /usr/loc

also verify it its listening on port specified in server.xml

root@tux:~# netstat -nap | grep java

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 11507/java

Shutdown tomcat

root@tux:~# /etc/init.d/tomcat.server stop

Shutting down tomcat: Using CATALINA_BASE: /usr/local/tomcat

Using CATALINA_HOME: /usr/local/tomcat

Using CATALINA_TMPDIR: /usr/local/tomcat/temp

Using JAVA_HOME: /usr/local/jdk

Next open a browser and type http://:

For eg http://machine:8080

You will see tomcat page

You can admin tomcat from http://:/admin

eg

http://machine:8080/admin

manager url http://

give username/password specified in tomcat-users.xml with admin/manager role

like

rolename="manager"/>

rolename="admin"/>

admin,manager"/>