Sunday, August 24, 2008

linux p2v: Migrating from one hardware to other

No matter how good the hardware is, eventually it dies. All my servers are dying one by one. Initially they have kernel panic sometimes then the frequency of kernel panics increase.
The challenge that I have always faced is how do I take all the applications running on server to another one? Reinstalling everything on a new machine is obviously not an option as I don't know what all is running and who is the current owner of which application.
So now I have started making VM of a server when it shows signs of old age. The usual p2v stuff did not help me much. Eventually I am able to do create the VM. Here is how to do it, for an experienced admin.
1) Install bare minimum OS on the new server. Preferably same version (major/minor etc). If you can not get the same version then get next up version from the same distribution (debian,fedora etc).
2) Boot the machine with a live cd (knoppix is my favorite) and delete everything except /boot and /lib/modules/ directory from the hard disk of the new machine.
3) Now tar these two directories and put st some secure place.
4) Boot the original machine also using a live cd and copy all the files using tar command itself. Execute the command like this:
tar -C -czvf - ./ | ssh root@new_mcahine tar -C -xzvf -
5) Now restore the the previously stores /boot and /lib/modules form secure place to new machine (using the live cd booted environment itself)
6) Edit the /etc/fstab to have correct entries.
7) Boot with a grub floppy and use setup command to setup grub.
8) Now reboot and if needed do the repair.

These instructions are useful to someone who knows what they are doing so may not be useful to linux novices. let me know if you have questions thru the comments here and my be I can help.

if you have lvm on the original machine, it becomes very difficult and you may have to edit the initrd image to make sure that lvm and hdd drivers are part of the initrd image.

Copying huge files to/from remote servers.

If you want to copy huge file (in Gigabytes) to remote servers you can not afford to let the connection break. But it happens all the time specially when you are using vpn.

If you have ssh access to the remote machine then you can use rsync over ssh channel to copy files. This approach is better than using scp because rsync has "resume" feature that restarts the copying from where is was aborted.
The syntax is like this:
If you want to copy from local machine to remote machine:
rsync -av -e ssh source_path username@remotemachine:/destination_path

If you want to copy from remote machine to local machine:
rsync -av -e ssh username@remotemachine:/source_path destination_path
(Please note that the above written commands are all on one line)

Tuesday, August 19, 2008

Weird glassfish error

I was experimenting with Glassfish today and encountered this error:
[#|2008-08-20T01:59:37.128+0000|SEVERE|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=11;_ThreadName=main;_RequestID=8db54f8d-759a-446b-96d2-1c8856d01776;|CORE5071: An error occured during initialization
com.sun.appserv.server.ServerLifecycleException: Cannot bind to URL [rmi://0.0.232.95:5586/management/rmi-jmx-connector]: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: Exception creating connection to: 0.0.232.95; nested exception is:
java.net.SocketException: Invalid argument or cannot assign requested address]|#]

Look at the server name: 0.0.232.95
That was strange. Upon investigation it turned out that my server name is 59487. This kind of numerical host names are typically assigned to the servers in hosted environments. If you write this number in hex then it becomes: E85F
Now somehow it gets converted in a 4 byte number and then that number is treated as an IP address. So here is what happens:
E85F--> 0000E85F---> 00.00.E8.5F --> 00.00.232.95

Mystery solved.

Wednesday, November 7, 2007

Will moon fall upon earth someday?

I was thinking about tidal waves. From what I know there source of energy is the rotation of moon.The simplistic view suggests that moon's kinetic (rotational) energy is what is getting converting into all kind of energy thru tidal waves. It implies that there is energy loss everyday. Does it mean that Moon will fall onto Earth? Or will it spin away?

Tuesday, October 30, 2007

Interactive TV, making a buddha out of you.


There is an interesting thing called Interactive TV. Nowadays, it has lot of mind share in Cable world. The whole food chain is very busy churning out iTV specs, tools, white papers, conducting seminars, workshops and doing everything else that makes it a dynamic field.
iTV is all about making the TV interactive. It does so not by making the TV interactive but, adding another component called set top box, which is like a PC with VCR like looks. The funny part about the set top is that you can not put the TV set on top of it, it will get crushed, unless you use an Entertainment Center (Do you think it is funny? You can ask TBS Superstation!). The not funny part is that these modern set top boxes always lag a modern PC by a decade in terms of hardware and software available on them.
Coming back to the point,
Today, if one watches a soap or game, he or she is completely involved in it. Or at least the producers want it to be like that. Success of a show is gauged by how involving it is. The idea is the viewer does not flip the channel and they can show the ad. If you thought purpose of cable company is show entertaining programs, get it right. The purpose is to show ads. They use sports, news, soap, reality show and all to fill the space between advertisements. Any way, a good show captures all the attention of the viewer. So if Jack and Jill are fighting over who will clean the kitchen after the party, A good director will make the viewers empathize with Jack or Jill.
But that will change with iTV. A typical application that iTV experts have been trying to get going since last couple of years is being able to conduct polls in real time, thankfully none of such application has gone beyond the state of being hacked-demos yet. With such applications, the user can have their say about the bout between Jack and Jill. This is the time when buddha jumps into the story.
A important theme in Yoga is the ability to split your brain into to two, one performer and the other observer. Buddha is a state of such Yogic achievement. iTV will enable all of us to become buddhas by making up for the observer part. So when you will be watching the Jack and Jill fight, while iTV will be observing you watching the fight. And suddenly when you are about to feel strongly about why Jack should the cleanup, iTV will pop up a question, Do you think Jack and Jill will make out after the fight? Select A key for Yes and B key for No.
You can't be non opinioned about this? Can you?
So iTV has a malign unintended consequence of detaching viewer from the show he is watching but a benign unintended consequence of fast track to becoming buddha.
Can't complain about this.

Monday, August 13, 2007

Teching a kid how to read.

My daughter is 5 years old and we are trying to teach her reading. My wife enrolled her in local Kumon classes. They started giving their worksheet and my wife made my daughter do them.

It was useful exercise initially, till she could learn alphabets. After that it kind of stalled. She was not able to read even simple words like cat and rat.
I think there is a problem with with the approach that was adopted to teach her. What they were trying to do is teach English as a phonetic language. They were teaching the sounds of the consonants and vowels separately. Then encouraging the kids to join them together.
After several failed attempts I gave up on that approach. I prepared this table for my daughter and taught her the pronunciation of the consonant and vowel together.



a

e

i

o

u

b

ba

be

bi

bo

bu

c

ca

ce

ci

co

cu

d

da

de

di

do

du

f

fa

fe

fi

fo

fu

g

ga

ge

gi

go

gu

h

ha

he

hi

ho

hu

j

ja

je

ji

jo

ju

k

ka

ke

ki

ko

ku

l

la

le

li

lo

lu

m

ma

me

mi

mo

mu

n

na

ne

ni

no

nu

p

pa

pe

pi

po

pu

r

ra

re

ri

ro

ru

s

sa

se

si

so

su

t

ta

te

ti

to

tu

w

wa

we

wi

wo

wu

y

ya

ye

yi

yo

yu

z

za

ze

zi

zo

zu

So effectively she had to memorize about 90 combination. it took her about 4 days ( 1 hours each day).
Equipped with this knowledge she was able to read lot of words which encouraged her to read more and as and when new combination cam she learned them.
Here is how it was:
After memorizing this table:
Was I mad? Yes dad.
Can I sit on mat?
Rat and cat ran on his bed.

and then gradually,
Will you play with me? Yes, said the small boy.

I thought I will just post it, may be someone will find it useful.

Sunday, August 12, 2007

Ubuntu and Win2k

I recently installed Win2k in another partition and quite surprisingly it did not mess up my Ubuntu installation.
Initially I had Win2k only. But then I installed Ubuntu (Feisty Fawn) and it really took care of my windows installation by putting it under chain loader. I was thinking this new installation of Win2k will mess up Ubuntu but not it appeared as another option in the chain loader itself. That was good.
Anyway I liked Ubuntu but it was kind of slow (specially Beryl almost killed it) but I am not upgrading my hardware soon.
So back to windows in another partition.