Sunday, March 13, 2011

Linux PXE-Boot Process

This documents how to setup a PXE boot server for Linux. This assumes that you're using Redhat/FC as the PXE boot server.
The first thing to note is that you need to setup your own mini-network that is completely disconnected from the network, since part of this process requires setting up a DHCP server which could conflict with the corporate DHCP server if they were both running on the same network simultaneously. So get yourself a switch from IT up front. You do *NOTneed the switch immediately.
The next step is to choose a box to be the PXE boot server. This can really be any box at all, as long as you have a NIC in it that works reliably under Linux. For the purposes of this documentation, I'm going to assume that you've loaded Fedora Core 4 on this box (do that now, if you've not already). Get this box onto the network with DHCP (just like a normal installation).
Next you'll need to install the following packages (which ship with FC4 already, so if you did an 'everything' OS install, you should have them already. If not, you can install them easily with yum):

tftp-server
dhcp
httpd
syslinux

If you use yum to install them, then it will be generally alot easier:
yum install tftp-server dhcp httpd syslinux
answer Y to all dependency/installation questions
Now you need to setup the DHCP server. With the FC4 RPM for dhcp, all you need to do is create /etc/dhcpd.conf with the following contents:

ddns-update-style interim;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.254;
default-lease-time 3600;
max-lease-time 4800;
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1;
option subnet-mask 255.255.255.0;
option domain-name "domain.net";
option time-offset -8;
}

host domain1 {
hardware ethernet 04:4B:80:80:80:03;
fixed-address 192.168.0.254;
option host-name "domain1";
filename "pxelinux.0";
}
This sets up a DNS server that will assign IP address 192.168.0.254 to your client box that has MAC address 04:4B:80:80:80:03 assigned to its PXE-boot capable NIC. Another thing to note is that we're reserving the private 192.168 subnet for this setup. The only thing you need to change in the above, is the MAC address to match that of the NIC on your client box.


Next you need to activate tftp within xinetd. All that is neccesary is to change disable=yes to disable=no in /etc/xinetd.d/tftp . Then restart xinetd. For future reference, the tftp RPM for FC4 stores its servable content under /tftpboot.


Now we need to setup your PXE server to use a static IP on the new private subnet. Create the file /etc/sysconfig/network-scripts/ifcfg-eth0.static with the following contents:
DEVICE=eth0
BOOTPROTO=STATIC
ONBOOT=no
TYPE=Ethernet
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
Now we need to setup the PXE boot environment on the server. To do this, you need to have either the Linux distribution that you wish to install over PXE either in CD format, or all the content of the CDs available on the network.
On the first CD of every RH/FC distribution there is a subdirectory called 'isolinux'. In that directory you will find two files, vmlinuz and initrd.img. These are the kernel & initrd.img that the RH/FC bootable CDs use to get the installer (anaconda) booted for performing the installation. Copy both of those files into /tftpboot and make sure that they are world readable. If you are planning to allow more than one version/distribution to be PXE boot installable, then you should rename both files so that its clear that they are for whatever version/distribution they came from (such as vmlinuz-RHEL4, initrd-RHEL4).
Next, you need the actual pxe boot linux kernel (what is actually run immediately after your PXE boot client box gets a DHCP lease). In this case, that file is pxelinux.0, and is part of the syslinux RPM. For FC4, you can find it at/usr/lib/syslinux/pxelinux.0. Copy that file into /tftpboot and make sure that it is readable to others.

Next we need to configure pxelinux. First create the directory /tftpboot/pxelinux.cfg (and make it readable to others). Inside that directory you need to create a number of zero size files (use touch):
01-04-4B-80-80-80-03
C
C0
C0A
C0A8
C0A80
C0A800
C0A800F
C0A800FE
01-04-4B-80-80-80-03
 The first 8 are the hex representation of the 192.168.0.254 IP address that your PXE boot client will be assigned. The permutations allow a broader IP subnet to be searched first for matches. The last entry is the MAC address of your PXE boot client's NIC (with dashes substituted for the colons), with '01' pre-pended. The "01" at the front represents a hardware type of Ethernet, so pxelinux.0 see's the configuration string as an IP address.

Now create the default pxelinux configuration inside the new file
/tftpboot/pxelinux.cfg/default:
prompt 1
default linux
timeout 100

label linux
kernel vmlinuz
append initrd=initrd.img ramdisk_size=9216 noapic acpi=off


Now you need to put the full contents of your Linux distro (all CDs) somewhere on disk. I put it under /tftpboot/RHEL4U1. In order to allow for installation over HTTP (apache), edit /etc/httpd/conf/httpd.conf and add the following:

Options Indexes
AllowOverride None

Alias /linux /tftpboot/RHEL4U1



At this stage, you're ready to hook up the switch. You should have CAT5 running between the switch & the PXE boot server, and the client box.


On the PXE boot server, bring down your DHCP network connected eth0 (ifdown eth0), disconnect the CAT5 connected to the network, and plug in the cat5 connected to your private switch. Now bring up the static IP for the PXE server with (ifup eth0.static). You can verify that it came up successfully by verifying that you have IP address 192.168.0.2 in ifconfig.


 Now start dhcpd & apache and activate tftp by running the following:
service dhcpd start
service xinetd restart
service httpd start
 and verify that they are all in your process list.

Plug the PXE client box's CAT5 into the switch, and verify that the NIC appears first in the BIOS boot order. (re)boot and you should get a DHCP lease, and start booting successfully off the network.

When you get into the RH/FC installer which asks you for the install method, choose HTTP. Fill in 192.168.0.2 for the name, and 'linux' for the path, and you should be all set.

If you run into any problems, check /var/log/messages for errors. /var/log/httpd is where apache logs, but if you get that far, your problem is an apache configuration/setup issue, and not a PXE boot issue.

VI editor Cheat Sheet


Modes

Vi has two modes insertion mode and command mode. The editor begins in command mode, where the cursor movement and text deletion and pasting occur. Insertion mode begins upon entering an insertion or change command. [ESC] returns the editor to command mode (where you can quit, for example by typing :q!). Most commands execute as soon as you type them except for "colon" commands which execute when you press the ruturn key.



Quitting

:xExit, saving changes
:qExit as long as there have been no changes
ZZExit and save changes if any have been made
:q!Exit and ignore any changes



Inserting Text

iInsert before cursor
IInsert before line
aAppend after cursor
AAppend after line
oOpen a new line after current line
OOpen a new line before current line
rReplace one character
RReplace many characters



Cursor Movement

hMove left
jMove down
kMove up
lMove right
wMove to next word
WMove to next blank delimited word
bMove to the beginning of the word
BMove to the beginning of blank delimted word
eMove to the end of the word
EMove to the end of Blank delimited word
(Move a sentence back
)Move a sentence forward
{Move a paragraph back
}Move a paragraph forward
0Move to the begining of the line
$Move to the end of the line
1GMove to the first line of the file
GMove to the last line of the file
nGMove to nth line of the file
:nMove to nth line of the file
fcMove forward to c
FcMove back to c
HMove to top of screen
MMove to middle of screen
LMove to botton of screen
%Move to associated ( ), { }, [ ]



Deleting Text

Almost all deletion commands are performed by typing d followed by a motion. For example, dw deletes a word. A few other deletes are:
xDelete character to the right of cursor
XDelete character to the left of cursor
DDelete to the end of the line
ddDelete current line
:dDelete current line



Yanking Text

Like deletion, almost all yank commands are performed by typing y followed by a motion. For example, y$ yanks to the end of the line. Two other yank commands are:
yyYank the current line
:yYank the current line



Changing text

The change command is a deletion command that leaves the editor in insert mode. It is performed by typing c followed by a motion. For wxample cw changes a word. A few other change commands are:
CChange to the end of the line
ccChange the whole line



Putting text


pPut after the position or after the line
PPut before the poition or before the line



Buffers

Named buffers may be specified before any deletion, change, yank or put command. The general prefix has the form "c where c is any lowercase character. for example, "adw deletes a word into buffer a. It may thereafter be put back into text with an appropriate "ap.



Markers

Named markers may be set on any line in a file. Any lower case letter may be a marker name. Markers may also be used as limits for ranges.
mcSet marker c on this line
`cGo to beginning of marker c line.
'cGo to first non-blank character of marker c line.



Search for strings

/stringSearch forward for string
?stringSearch back for string
nSearch for next instance of string
NSearch for previous instance of string



Replace

The search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command (below).
:s/pattern/string/flagsReplace pattern with string according to flags.
gFlag - Replace all occurences of pattern
cFlag - Confirm replaces.
&Repeat last :s command



Regular Expressions

. (dot)Any single character except newline
*zero or more occurances of any character
[...]Any single character specified in the set
[^...]Any single character not specified in the set
^Anchor - beginning of the line
$Anchor - end of line
\<Anchor - begining of word
\>Anchor - end of word
\(...\)Grouping - usually used to group conditions
\nContents of nth grouping


Regular Expression Examples
/Hello/Matches if the line contains the value Hello
/^TEST$/Matches if the line contains TEST by itself
/^[a-zA-Z]/Matches if the line starts with any letter
/^[a-z].*/Matches if the first character of the line is a-z and there is at least one more of any character following it
/2134$/Matches if line ends with 2134
/\(21|35\)/Matches is the line contains 21 or 35
Note the use of ( ) with the pipe symbol to specify the 'or' condition
/[0-9]*/Matches if there are zero or more numbers in the line
/^[^#]/Matches if the first character is not a # in the line
Notes:
1. Regular expressions are case sensitive
2. Regular expressions are to be used where pattern is specified


Ranges

Ranges may precede most "colon" commands and cause them to be executed on a line or lines. For example :3,7d would delete lines 3-7. Ranges are commonly combined with the :s command to perform a replacement on several lines, as with :.,$s/pattern/string/g to make a replacement from the current line to the end of the file.
:n,mRange - Lines n-m
:.Range - Current line
:$Range - Last line
:'cRange - Marker c
:%Range - All lines in file
:g/pattern/Range - All lines that contain pattern



Files

:w fileWrite to file
:r fileRead file in after line
:nGo to next file
:pGo to previos file
:e fileEdit file
!!programReplace line with output from program



Other

~Toggle upp and lower case
JJoin lines
.Repeat last text-changing command
uUndo last change
UUndo all changes to line

Migrate from Oracle to Netezza


Following are the major steps involved in Oracle to Netezza migration:
  1. Capture DDL, you may use “dbms_metadata.get_ddl” to capture all table definitions. Change varchar2 to varchar, does not really matter if char is more than 16 characters; stored the same way if more than 16 characters. Number is either numeric or float type. Timestamp can be either data or time. This is the most time consuming part and mostly done manually though tools are available, such as ErWin reverse engineering.
  2. Most important for Netezza is distribution of data on SPU or disk. Choose distribution for each table, you may like to pick up only a handful fields for distribution of data for tables across the entire database. Recommended to use only one distribution key (field) per table, not multiple fields. For small tables, Netezza broadcasts to host where data gets sent to all SPU or nodes; this is similar to replicate in other appliances.
  3. With steps (1) and (2) above, DDL are created on Netezza. Create a user and / or group and assign permissions.
  4. You may like to NFS mount Netezza binaries on Oracle host (OR) Oracle file system on Netezza. I prefer the first one, if Oracle system guys do not object.

Mouting NFS from NZ host to Oracle:

Oracle to Netezza migration typically involves spooling data out as a flat text file and using nzload to seed data.
A) These are contents of /etc/export after making changes for allowing Oracle system to access NFS mount. Last line is added for this purpose. IP address for illustration purpose: Oracle (10.11.12.13) & Netezza (10.10.11.11).
[root@NZ_host1 ~]# cat /etc/exports
# NPS setup — do not edit below this line — NFS
/nz/export      10.0.0.2/16(rw,async,insecure,anonuid=500,anongid=500)
# NPS setup — do not edit above this line — NFS
# For exporting as NFS mount on to Oracle
/nz/kit         10.11.12.13/255.255.255.255(sync,no_root_squash,rw)
B) Issue this command at Netezza host
[root@NZ_host1 ~]# exportfs -ra
C) Make a new directory on Oracle, for example: /home/oracle/NZ_bins
D) On Oracle system, do a mount command
[root@ora_dw1 /]# mount -t nfs 10.10.11.11:/nz/kit /home/oracle/NZ_bins
Once mounted, you should see binaries under bin directory (/home/oracle/NZ_bins). If you are trying to load using nzload, you may encounter a problem with password. You need to cache password on the local host first.
[oracle@ora_dw1 bin]$ nzpassword add -u admin -pw password -host 10.10.11.11
[oracle@ora_dw1 bin]$ ./nzload -host 10.10.11.11 -u nzadmin1 -pw zzadmin1 -db dw_db1 -t day_time_t -delim ‘|’ -df /tmp/1
Above should load data into remote netezza database. If done, go to Netezza host and use nzsql to find number of rows inserted. Check on Oracle row count.

NZLOAD can be streamed using UNIX named pipes. That is, first do ‘mkfifo /oraExport/fifo.tmp’ for example. Then, spool Oracle data and write to this file (spool /oraExport/fifo.tmp). Assuming Netezza binaries are available (see above steps), load directly on to Netezza host.

Netezza Architecture

IBM published Netezza architecture on their red book site after its acquisition,


Netezza Architecture

About Me

My photo
Tirunelveli, Tamilnadu, India
Hai friends! I am Siva, from Nellai. Working as a software engineer. Blogging is my free time activity.

VISITS COUNTER

Visitors Online Counter