Monday, May 28, 2007

Setting up Ubuntu common stuff

Repositories:

First of all, a basic know how about the application manager. Ubuntu is Debian based and has an excellent integration of "apt-get" or "aptitude" which is the default application manager.
Now we will add software repositories for aptitude to download and install various applications as per our need, for which visit http://www.ubuntu-nl.org/source-o-matic where you select the version of Ubuntu you are using and the architecture. This will generate the list of all the valid available repositories from where we can download the applications that we require. Copy all the lines that are generated and follow these steps:

uniks@uranium:~$ sudo mv /etc/apt/sources.list /etc/apt/sources.list.ORIG
uniks@uranium:~$ sudo gedit /etc/apt/sources.list

This should backup the current sources.list and open a copy of the same for editing in GEDIT editor. Paste all the lines generated by SOURCE-O-MATIC in this file and

uniks@uranium:~$ sudo apt-get update
uniks@uranium:~$ sudo apt-get upgrade

Optionally, if you are using Ubuntu 7.04 (Fiest) you can add these to sources.list:
deb http://us.archive.ubuntu.com/ubuntu fiesty main restricted
deb-src http://us.archive.ubuntu.com/ubuntu fiesty main restricted

## MAJOR BUG FIX UPDATES produced after the final release
deb http://us.archive.ubuntu.com/ubuntu fiesty-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu fiesty-updates main restricted

## UBUNTU SECURITY UPDATES
deb http://security.ubuntu.com/ubuntu fiesty-security main restricted
deb-src http://security.ubuntu.com/ubuntu fiesty-security main restricted

deb http://security.ubuntu.com/ubuntu fiesty-security universe
deb-src http://security.ubuntu.com/ubuntu fiesty-security universe

## UNIVERSE AND MULTIVERSE REPOSITORY (Unsupported by Ubuntu. Use at own risk.)
deb http://archive.ubuntu.com/ubuntu fiesty universe multiverse
deb-src http://archive.ubuntu.com/ubuntu fiesty universe multiverse

## PLF REPOSITORY (Unsupported. May contain illegal packages. Use at own risk.)
deb http://packages.freecontrib.org/ubuntu/plf fiesty free non-free
deb-src http://packages.freecontrib.org/ubuntu/plf fiesty free non-free
Now we are all set to get things running. You can install packages using
sudo apt-get install like

uniks@uranium:~$ sudo apt-get install gftp
where, gftp is the package name.

Installing Multimedia Codecs

Issue the following commands:

uniks@uranium:~$ sudo apt-get install gstreamer0.10-plugins gstreamer0.10-lame gstreamer0.10-ffmpeg gstreamer0.10-lame lame sox ffmpeg mjpegtools vorbis-tools w32codecs gst-register-0.10 libmad0

DVD Playback:

uniks@uranium:~$ sudo apt-get install libdvdcss2




Monday, May 14, 2007

Linux High Availablity CLUSTER

Hardware configuration that I used for making a cluster:

clusternode1: Intel P4 2.66 GHz., 256 MB RAM, Two ethernet adapters.
clusternode2: Intel P4 2.4 GHz., 512 MB RAM, Two ethernet adapters.

I assigned clusternode1 which I will be calling CN1's eth0 with an IP 10.31.15.221 and clusternode2 which I will be calling CN2's eth0 with 10.31.15.222. I have kept 10.31.15.223 reserved for later use as we will be using this IP as our cluster IP, which of course will be a virtual IP :)

Now I assign eth1 interface for the 2 CNs i.e. CN1's eth1: 192.168.0.1 and CN2's eth1: 192.168.0.2.

The eth1 interface will be used for heartheat check and will be having its seperate network which will not be talking to the LAN in any way, where as the eth0 will be connected to the LAN.

Installation:

Prerequisites:

The following packages are required before we can start with the installation for the heartbeat application:
(Note: you will require to check the versions compatible with you current operating system and install as per your operating system recommendations, the versions mentioned below are the ones that were compatible with the OS I was using and they need not be the same)
  • perl-Authen-SASL-2.08
  • perl-Convert-ASN1-0.18
  • perl-Crypt-SSLeay-0.51
  • perl-Digest-HMAC-1.01
  • perl-Digest-SHA1-2.01
  • perl-IO-Socket-SSL-0.96
  • perl-ldap-0.3202
  • perl-Mail-IMAPClient-2.2.9
  • perl-Net-DNS-0.31-3
  • perl-Net-SSLeay-1.22-2
  • perl-Parse-RecDescent-1.94
  • perl-XML-NamespaceSupport-1.08
  • perl-XML-SAX-0.12

We will now require to install the following packages:
  • heartbeat
  • heartbeat-ldirectord
  • heartbeat-pils
  • heartbeat-stonith
For Fedora:
# yum install heartbeat
#
yum install heartbeat pils stonith ldirectord

For Debian/Ubuntu:
# apt-get install heartbeat pils stonith ldirectord

For RHEL-compatible:
RPMs are available for download at:
i386: http://mirror.centos.org/centos/4/extras/i386/RPMS/
x86_64: http://mirror.centos.org/centos/4/extras/x86_64/RPMS/

For Gentoo:
#
emerge heartbeat


Configuration of Heartbeat and Apache:

Post installation, edit /etc/ha.d/authkeys and add the following two lines:

auth 1
1 crc

Also, edit the /etc/ha.d/ha.cf to include the following lines:

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
deadtime 5 # how long before the host is declared down
udpport 694 # UDP port used for broadcasting
bcast eth1 # interfaces to broadcast heartbeats
auto_failback on
node CN1 # Defining which machine is a part of cluster
node CN2 # Defining which machine is a part of cluster

Now edit the /etc/ha.d/ha.cf/haresources which will look like:

mycluster 10.31.15.223 httpd # here, mycluster is the clustername that will appear when I issue uname -n.

After which, start/restart httpd:

# /etc/ha.d/httpd start
OR
# /etc/init.d/httpd

When done with the configuration of CN1, you can copy the files to CN2. In /etc/ha.d/rc.d you will find the script called ip-request which will do the job of assigning the ip address etc.
now start /etc/rc.d/init.d/heartbeat on both machines.

Install a different index page on the machines to be served by the http server, using below commands.

echo hello world from CN1 > index.html

echo hello world from CN2 > index.html

Note: Ensure that on both nodes, httpd does not start when the OS boots

Testing the failover cluster:

Ensure that you are able to browse the page http://10.31.15.223 and it shows “index.html” of CN1.

Now, shut down or remove both the network cables of clusternode1 and try to browse the page http://10.31.15.223 and it should show the “index.html” of CN2. You can also verify the IP 10.31.15.223 assigned to CN2 by using ifconfig command or also by reading the log file /var/log/ha-debug.

To keep a synchronization you can setup a cronjob to copy the data from CN1 of /var/www/html to CN2 /var/www/html. I would recommend using rsync for this ;))