Tuesday, February 21, 2012

Linux bond or team multiple network interfaces (NIC) into single interface


Linux allows binding multiple network interfaces into a single channel/NIC using special kernel module called bonding. According to official bonding documentation, "The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical "bonded" interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed."
Step #1: Create a bond0 configuration file
Red Hat Linux stores network configuration in /etc/sysconfig/network-scripts/ directory. First, you need to create bond0 config file:
# vi /etc/sysconfig/network-scripts/ifcfg-bond0
Append following lines to it:
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
Replace above IP address with your actual IP address. Save file and exit to shell prompt.
Step #2: Modify eth0 and eth1 config files:
Open both configuration using vi text editor and make sure file read as follows for eth0 interface
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Modify/append directive as follows:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Open eth1 configuration file using vi text editor:# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Make sure file read as follows for eth1 interface:
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Save file and exit to shell prompt.

Step # 3: Load bond driver/module
Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file:
# vi /etc/modprobe.conf
Append following two lines:
alias bond0 bonding
options bond0 mode=balance-alb miimon=100
Save file and exit to shell prompt. You can learn more about all bounding options in kernel source documentation file (click here to read file online).
Step # 4: Test configuration
First, load the bonding module:
# modprobe bonding
Restart networking service in order to bring up bond0 interface:
# service network restart
Verify everything is working:
# less /proc/net/bonding/bond0
Output:
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63
List all interfaces:# ifconfig

Output:
bond0     Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
 RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0
 RX bytes:250825 (244.9 KiB)  TX bytes:244683 (238.9 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:251161 (245.2 KiB)  TX bytes:180289 (176.0 KiB)
 Interrupt:11 Base address:0x1400

eth1      Link encap:Ethernet  HWaddr 00:0C:29:C6:BE:59
 inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
 inet6 addr: fe80::20c:29ff:fec6:be59/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:4 errors:0 dropped:0 overruns:0 frame:0
 TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000
 RX bytes:258 (258.0 b)  TX bytes:66516 (64.9 KiB)
 Interrupt:10 Base address:0x1480

PXE Installation


Red Hat allows you to install the OS over the network using NFS, FTP or HTTP. If the hardware supports PXE (Pre-eXecution Environment) the NIC card will send out a broadcast request for DHCP information. The DHCP server provides the client with a IP address and other network infomation such as the TFTP server address (which provides the files necessary to start the installation) and the location of the files on the TFTP server. This is possible because of PXELINUX, which is part of the syslinux package.
In order to setup a PXE installation the following must be carried out:
  • Install the necessary packages
  • Configure the network (NFS, FTP, HTTP) server to export the installation tree (redhat packages, etc)
  • Configure the DHCP server
  • Configure the files on the tftp server necessary for PXE booting
  • Configure which hosts are allowed to boot from the PXE configuration
  • Configure the Kickstart file
  • Boot and start the installation
Software Packages (required)
The following software packages are required
  • tftp-server-*
  • tftp-client-* (for testing)
  • dhcp-*
  • xinetd-*
  • system-config-netboot-* (supplies the prelinux.0 file)
Installation Tree
In my examples below i have used the directory /export/kickstart but this could be anything you like.
Basically create the directory and share the directory to the world, then copy the complete fedora/RHEL dvd or cdroms to this directory, once copied you should have something simular to below
total 52
drwxr-xr-x 10 root root  4096 Oct  6 13:38 .
drwxr-xr-x  3 root root  4096 Oct  6 09:45 ..
drwxrwsr-x  4 root root  4096 Mar 15  2006 Fedora
drwxrwsr-x  3 root root  4096 Mar 15  2006 figs
drwxrwsr-x  4 root root  4096 Mar 15  2006 images
drwxrwsr-x  2 root root  4096 Mar 15  2006 isolinux
drwxr-xr-x  2 root root  4096 Oct  6 14:00 ks            (this is where my kickstart files are held)
drwx------  2 root root 16384 Oct  6 09:47 lost+found
drwxrwsr-x  2 root root  4096 Mar 15  2006 repodata
drwxrwsr-x  2 root root  4096 Mar 15  2006 stylesheet-images
DHCP Installation
Once the DHCP package has been installed, a basic configuration file needs to be setup in /etc/dhcpd.conf, again this configuration file can be has advanced as you want it to be.
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample 
ddns-update-style ad-hoc;

deny unknown-clients;
not authoritative;

option domain-name              "example.com";
option domain-name-servers      ???.???.???.???, ???.???.???.???;
option subnet-mask              255.255.255.0;

allow bootp;
allow booting;

option ip-forwarding    false;  # No IP forwarding
option mask-supplier    false;  # Don't respond to ICMP Mask req

subnet 192.168.0.0 netmask 255.255.255.0 {
  option routers        192.168.0.1;
}

group {
  next-server 192.168.0.50;          # name of your TFTP server
  filename "linux-install/pxelinux.0";        # name of the bootloader program

  host fedora5 {
        hardware ethernet 00:0C:29:D5:B8:A0;
        fixed-address 192.168.0.40;
  }
}
The above file will setup the host fedora5 (note the specific MAC address associated to the host fedora5) and boot from the next-server (tftp server) using the pxelinux.0 boot file, which in turn will look for the pxe configuration boot file.
PXE Boot Configuration Files
The PXE boot configuration basically is setting up the /tftpboot directory to allow clients to download the PXE boot configuration script and allow access to the initial ram disk (initrd.msg) and the linux kernel (vmlinuz).
The tftpboot directory will contain the following directories and files
/tftpboot/linux-install/prelinux.0
This file is the PXE boot file and will be run immediately after the the client has connected to the tftp server.
/tftpboot/linux-install/msgs
This directory contains the boot messages/menus displayed when the client boots
/tftpboot/linux-install/pxelinux.cfg
This directory contains the PXE boot configuration scripts, normally named C0A80023 (ip address of host in HEX)
/tftpboot/linux-install/RHEL4
This directory is optional and is created when using the system-config-netboot or pxeos commands. It is used to hold kickstart scripts, linux kernels and ram disks for specific installations.
Two commands are used to configure the tftpboot area pxeos and pxeboot
Using the command below will create a directory called RHEL4 and copy the necessary linux kernel and ram disk files (normally located in images/pxeboot directory of the installation tree), we are also stating that we will use NFS to install the OS onto clients
# pxeos -a -i "<description>" -p NFS -D 0 -S <tftp IP addr> -K nfs:<kickstartserver>:/export/kickstart -L /export/kickstart RHEL4
-a
Specifies that an OS instance is being added to the PXE configuration
-i
Description of the OS instance
-p
Specify which protocol to use for the o/s installation (NFS, FTP, HTTP)
-D
Specify if client is diskless (0=network, 1=diskless)
-s
Provides the name of the NFS, FTP or HTTP server
-L
Provides the location of the installation tree (o/s rpms, etc)
-k
provide the specific kernel version of the server installation tree for booting
-K
provide the location of the kickstart file
os-identifier
OS identifier to keep different build seperate
The above command would have copied the linux kernel (vmlinuz) and ram disk (initrd.msg) to the /tftpboot/linux-install/RHEL4 directory and also created a blank kickstart configuration file( i will be using my own kickstart file discussed later). Also the command would have created a pxe boot default file in the /tftpboot/linux-install/pxelinux.cfg directory as below:
default local
timeout 100
prompt 1
display msgs/boot.msg
F1 msgs/boot.msg
F2 msgs/general.msg
F3 msgs/expert.msg
F4 msgs/param.msg
F5 msgs/rescue.msg
F7 msgs/snake.msg


label 0
localboot 1


label 1
  kernel RHEL5/vmlinuz
  append initrd=RHEL5/initrd.img ramdisk_size=5939 ks=nfs:192.168.0.50:/export/kickstart/ks/default.ks
To setup specific pxe boot configuration files we use a command called pxeboot, this will override the above default boot configuration file
pxeboot -a -K <kickstart server> -O OS identifier <hostname>
-a
add a specific host
-K
location of kickstart file
-O
OS identifier
hostname
hostname
The above command will create a file called C0A80028 (IP address in HEX) located in /tftp/linux-install/pxelinux.cfg, which is the specific boot configuration file for that host.
default RHEL5

label RHEL5
          kernel RHEL5/vmlinuz
          append initrd=RHEL5/initrd.img  ramdisk_size=5939 ks=nfs:192.168.0.50:/export/kickstart/ks/default.ks
After the client has obtained it's IP address via DHCP it looks for the following configuration files, as you can see the C0A80028 file is called which if you remember was created above.
http://www.datadisk.co.uk/images/unix/pxeboot_1.JPG


Kickstart Configuration file
There are many options to a kickstart configuration file, i have supplied a basic one below which was obtain from a website on the internet, adapt to your own tastes.
install         # rather than upgrade
nfs --server=192.168.0.50 --dir=/export/kickstart  # Location of the install media, http, nfs etc
lang en_US.UTF-8
langsupport --default en_US.UTF-8
keyboard uk
mouse generic3usb --device input/mice
network --device=eth0 --bootproto=static --ip=192.168.0.40 --netmask=255.255.255.0 --gateway=???.???.???.??? --nameserver=???.???.???.??? -
-hostname fedoraks # we could specify static IP info too instead
rootpw password    # noencrypted password
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone Europe/London
bootloader --location=mbr --append="noexec=off hda=noide"
              # Any boot time options you wan to add
              # I specified noide here as I was booting
              # from SAN in this case.
skipx
              # do not configure X Windows
zerombr yes
              #Clear the Master Boot Record
clearpart --all --initlabel
              #Partition clearing information
part /boot --fstype ext3 --size=150 --ondisk=hda
part pv.01 --size=1 --grow --ondisk=hda
part pv.02 --size=1 --grow --ondisk=hda
volgroup rootvg pv.01
volgroup satvg pv.02
logvol /    --vgname=rootvg --size=6000 --name=rootvol
logvol swap --vgname=rootvg --size=2000 --name=swapvol
              # In the above partition layout (with LVM) I have
              # used two disks, sda and sdb for different volumes.
              # You don't need to use LVM etc. HDA for IDE etc.
auth  --useshadow  --enablemd5
              #System authorization information
%packages --resolvedeps
              # This is the actual package install section. The
              # resolvedeps option allows you to make mistakes and
              # have anaconda sort it out for you, i.e. resolving
              # package dependencies.
@ Base
@ Development Tools
@ Legacy Software Development
              # base channels
screen
newt-perl
perl-DateManip
PyXML
ntp
              # individual packages to add
-vim
-pico
-emacs
              # individual packages to add
%post
              # And so begins the post-install section.
              # this is currently in a chroot to / on the
              # new file system.
              # Various variables I like to set first to use later
(
              # I run everything in this, so I can log it
/bin/echo "Welcome to $HOSTNAME Server " > /etc/motd
/bin/echo "Built from kickstart version $VER " >> /etc/motd
/bin/echo " " >> /etc/motd
              # One way of adding to files
cat >> /etc/sysctl.conf << EOF
fs.aio-max-size = 1048576
fs.file-max = 327680
net.core.rmem_max = 262144
net.core.wmem_max = 262144
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_forward = 0
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
EOF
              # Another way of inputing to files
              # Here doing some system settings
useradd -c "Some lone user" -d /home/luser luser
echo luserpass | passwd --stdin luser
              # Add a user if you like
# Setup hosts file
cat > /etc/hosts << EOF
127.0.0.1       localhost.localdomain           localhost
192.168.0.1     install-server.some.domain      install-server
192.168.0.2     another.machine.some.domain     another
EOF
              # Edit the hosts file if you like
wget $SERVER/iptables.$lab -O /etc/sysconfig/iptables
              # Here using the server variable we set at the
              # top of the post-install section to pull some
              # custom files we stored, in this case a firewall.
              # In this case using a variable which could have been
              # pulled from /proc/cmdline to get a specific one for
              # each lab.
/sbin/chkconfig ip6tables off
/sbin/chkconfig isdn off
/sbin/chkconfig sendmail off
/sbin/chkconfig ntpd on
              # Turn some services on and off
) > /tmp/kickstart-install.log 2>&1
              # The aforementioned log.
Boot and Start the Installation
Just boot the server via the network (normally option F12) and if all goes well your client should install from the kickstart server, the basic steps are as follows
Client BIOS (DHCP broadcast)<----------------------------------------> DHCP Server (Network info, tftp server and PXE file name)
Client BIOS (TFTP request for pxelinux.0)<---------------------------> TFTP/PXE Server (supplies the pxelinux.0 file)
Running PXE (pxe request for kernel and Kickstart install)<----------> TFTP/PXE Server (C0A80028 or default file supplies info)
Running Kernel (NFS KICKSTART) <-------------------------------------> NFS Server (supplies the kickstart config file)
Running Anaconda (NFS request for rpms)<-----------------------------> NFS Server (supply RPMS)
Running Anaconda (NFS request post installtion) <--------------------> NFS Server (runs post install scripts)
Running Anaconda (reboot)

Configured PXE boot Server


Server IP (Static) 192.168.0.50
Host IP (thru DHCP) 192.168.0.30
Copy the entire contents of RHEL 5.4 DVD in to any of the directory (mine is /exports)
Create a kickstart file and place  it any directory (mine is /kickstart)
Grant 777 permission for ks.cfg and /exports and /kickstart
Install dhcp,tftp through yum
As tftp is xinetd service enable it in /etc/xinetd.d/tftp à disable=no
Chkconfig - - add  tftp
Now
Run these utilities
Syntax:
# pxeos -a -i "<description>" -p NFS -D 0 -S <tftp IP addr> -K nfs:<kickstartserver>:/export/kickstart -L /export/kickstart RHEL4
#pxeboot -a -K <kickstart server> -O OS identifier <hostname>

Red Hat Enterprise Linux / CentOS Linux Enable EPEL (Extra Packages for Enterprise Linux) Repository


 EPEL (Extra Packages for Enterprise Linux) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages that complement the Fedora-based Red Hat Enterprise Linux (RHEL) and its compatible spinoffs, such as CentOS and Scientific Linux.
EPEL provide lots of packages for CentOS / RHEL, It is not part of RedHat or CentOS but is designed to work with these major distributions. Please note that EPEL only provides free and open source software unencumbered by patents or any legal issues. In short you will not find mp3, dvd and music / media player under EPEL. However, you will find many programs related to networking, monitoring, sys admin, programming and so on.
Packages are supplied in RPM format and in most cases are ready to use. Beware that some packages may break something and you should not blindly install those packages.
How do I enable EPEL?
Simply type the following command as root user:

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm 
List new repo:
# yum repolist
Sample output:
Loading "skip-broken" plugin
Loading "fastestmirror" plugin
repo id              repo name                                 status
addons               CentOS-5 - Addons                         enabled
base                 CentOS-5 - Base                           enabled
epel                 Extra Packages for Enterprise Linux 5 -   enabled
extras               CentOS-5 - Extras                         enabled
updates              CentOS-5 - Updates                        enabled
Once installed use yum command to list, view and install the packages:
# yum search package-name
# yum install package-name

nmap – “Network Mapper”

nmap is a free and open source  utility for network exploration or security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. It was designed to rapidly scan large networks, but works fine against single hosts. Nmap runs on all major computer operating systems, and official binary packages are avalable for Linux, Windows, and Mac OS X. In addition to the classic command-line Nmap executable, the Nmap suite includes an advanced GUI and results viewer (Zenmap), a flexible data transfer, redirection, and debugging tool (Ncat), a utility for comparing scan results (Ndiff), and a packet generation and response analysis tool (Nping).

Monday, February 20, 2012

Recover Corrupted Partition From A Bad Superblock


If a filesystem check fails and returns the error message “Damaged Superblock”

Solution:
There are backups of the superblock located on several positions and we can restore them with a simple command. Backup locations are: 8193, 32768, 98304, 163840, 229376 and 294912. ( 8193 in many cases only on older systems, 32768 is the most current position for the first backup )
Now, suppose you get a ¨Damaged Superblock¨ error message at filesystem check ( after a power failure ) and you get a root-prompt in a recovery console, then you give the command:
# e2fsck -b 32768 /dev/hda5
System will then check the filesystem with the information stored in that backup superblock and if the check was successful it will restore the backup to position 0.
If this is not working try using the other copy of Superblock located at the above mention location in

error while loading shared libraries: libdb.so.2: cannot open shared object file: No such file or directory R12.1.1 Installation on Linux 5.6


I was Installing Oracle E-Biz R12.1.1 on OEL 5.6 - 64 Bit for one of our customer. All OS pre-requisites has been configured as per the MOS tech note for Installation and all pre-req check from the rapidwiz Installer went fine.

At last steps of Installation during validating system configuration it failed on HTTP, loginpage, Help Directory and JSP.

When checked all services were up and running except web server.

checking status of OPMN managed processes...

Processes in Instance: VIS_oel.oel.WORLD.com
---------------------------------+--------------------+---------+---------
ias-component                    | process-type       |     pid | status
---------------------------------+--------------------+---------+---------
OC4JGroup:default_group          | OC4J:oafm          |   13776 | Alive
OC4JGroup:default_group          | OC4J:forms         |   13703 | Alive
OC4JGroup:default_group          | OC4J:oacore        |   13617 | Alive
HTTP_Server                      | HTTP_Server        |   13560 | Down

Http_server is shown as Down.
Error messages recorded in logfiles:
Installation logfile:
HTTP
-----
Checking URL = http://oel.WORLD.com:8011

RW-50015: Error: - HTTP Listener is not responding. The service might not have started on the port yet. Please check the service and use the retry button.
Help Page
----------
checking URL = http://oel.WORLD.com:8011/OA_HTML/help

RW-50015: Error: - Help Page is not responding. The service might not have started on the port yet. Please check the service and use the retry button.
Virtual Directory
------------------
RW-50015: Error: - Http Server Virtual Directories is not responding. The service might not have started on the port yet. Please check the service and use the retry button.

JSP
----
checking URL = http://oel.WORLD.com:8011/OA_HTML/jtfTestCookie.jsp

RW-50015: Error: - JSP is not responding. The service might not have started on the port yet. Please check the service and use the retry button.
Login Page
-----------
RW-50015: Error: - Login Page is not responding. The service might not have started on the port yet. Please check the service and use the retry button.
RW-10001: Rapidinstall wizard has detected that your configuration has errors. You must resolve these issues before continuing.
Apache logfiles:
07/04/11-10:23:44 :: adapcctl.sh: starting OPMN managed OHS instance
opmnctl: starting opmn managed processes...
================================================================================
opmn id=OEL.WORLD.COM:6210
    0 of 1 processes started.

ias-instance id=VIS_oel.oel.WORLD.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--------------------------------------------------------------------------------
ias-component/process-type/process-set:
    HTTP_Server/HTTP_Server/HTTP_Server/

Error
--> Process (index=1,uid=83499476,pid=12821)
    failed to start a managed process after the maximum retry limit
    Log:
    /u02/oracle/VIS/inst/apps/VIS_oel/logs/ora/10.1.3/opmn/HTTP_Server~1.log
/u02/oracle/VIS/inst/apps/VIS_oel/ora/10.1.3/Apache/Apache/bin/apachectl startssl: execing httpd
/u02/oracle/VIS/apps/tech_st/10.1.3/Apache/Apache/bin/httpd: error while loading shared libraries: libdb.so.2: cannot open shared object file: No such file or directory
Cause:
http web server unable to start due to missing library.
Solution:
1) Shutdown all application services.
2) create link for library file as below
ln -s   /usr/lib/libgdbm.so.2.0.0  /usr/lib/libdb.so.2
3) Startup all application services.
Now you should be able to access the application.