Monday, July 30, 2012

Dnstracer


You can trace a chain of DNS servers to the source and troubleshooting dns issues with dnstracer command.

dnstracer www.google.com

OR try old good dig :)

dig +trace www.google.com


Trace using IPv4 and IPv6 root servers:

dnstracer -4 -s . www.google.com
dnstracer -6 -s . www.google.com


                                                                                                                                          ============
                                                                                                                                                                                                                            Thnx Nixcraft
                                                                                                                                                                                                                             ============

Wednesday, July 18, 2012

LINUX BOOTING SEQUENCE TROUBLESHOOTING

LINUX BOOTING SEQUENCE TROUBLESHOOTING
Case 1: No boot loader splash screen or prompt appears
Cause:
1) Grub.conf miss configures
2) Initrd misplaced or deleted
3) MBR cruuppet
4) /boot partition miss
Grub.conf miss configures
Remedy: try to pass boot location initrd location & kernel module location as follows
Step a) Grub > root (hd0,0)
Note: here hd0,0 means boot partition is in 1st partition of 1st hdd.(please use hd for SATA & SCSI hdd also )
Step b) grub > kernel /vmlinuz-$(uname -r) root=LABEL=/ rhgb quiet
Step c) grub > initrd /initrd-$(uname -r).img
Step d) grub > boot
Then after rebooting try to recreate grub.conf file
Initrd misplaced or deleted
Case a) system is up
This is the most fortunate situation for system admins who are managing the server remotely because now once the system will down it will not be up without rescue mode
Remedy:
[root@dh-localhost ~]# mkinitrd /boot/ initrd-$(uname -r).img $(uname -r)
Case b) system is down
Then boot from system via DVD & start it by rescue mode
Remedy:
Step 1) Boot: linux recue
After some process & ittrective prompt you will be on sh prompt
Step 2) chroot /mnt/sysimage
cd /boot
mkinitrd /boot/ initrd-$(uname -r).img $(uname -r)
Then reboot the system by HDD
Note: - in case of fstab is also misconfigured (ie / & other partition will not mount after boot) then chroot command will not work. So in this case your 1st step would be to correct fstab then perform above steps as follows
Step a) boot from DVD or other bootable media
Step b) chroot /mnt/sysimage (you will find chroot error here )
Step c) mkdir /test
e2label /dev/sda1 (if it will show boot them mount it otherwise try to search by e2label /dev/sda2 ownwards)
mount /dev/sda1 /test
cd /test
cd grub
vi grub.conf (please make it correct)
mkdir /data
mount /dev/sda2 /data (mounting / partition on /data )
cd /data
cd /etc
vi fstab (please correct it )
Then reboot the system & follow previous step
Mbr corrupt
Case a) system is up
Method 1
[root@dh-localhost ~]# /sbin/grub-install /dev/sda
Method 2
[root@dh-localhost ~]# grub
grub> root (hd0,0)
grub > setup (hd0)
grub > quit
Case b) system is down
Boot system by rescue mode
Sh #Chroot /mnt/sysimage
Sh # /sbin/grub-install /dev/sda
Note : A smart system admin always take backup of MBR as follows
[root@dh-localhost ~]# dd if=/home/mbr of=/home/mbr bs=1 count 500
&
For restoration for MBR
[root@dh-localhost ~]# dd if=/home/mbr of=/home/mbr bs=1 count 500
/boot partition miss
In this case if you have backup of /boot then you can recover it otherwise you need to rebuild the server again.

Recover LVM from Corrupted physical volume/Disk

Recover LVM from Corrupted physical volume

I had Volume Group /dev/vg1 that consist two physical volumes /dev/sdb1 and /dev/sdc1 . One of physical volume /dev/sdc1, corrupted due to disk problem , now the challenge was to recover LVM. I decided to use pvremove command, in following way
    root#pvremove /dev/sdc1
Above command displayed error couldn't find device uuid 'xxxxxxx'
Then issue tried forcefully
   root#pvremove -ff /dev/sdc1
After some warning, it removed that physical volume.
Then i issued pvdisplay command
 root#pvdisplay
This display message  ' Couldn't find device with uuid xxxxxx'

Now what you need to do is to create a physical volume with new disk with missing uuid .
For that following command can be used
root# pvcreate --uuid=xxxxxx /dev/sdd1 --restorefile=/etc/lvm/archive/vg0_0.vg
Where /dev/sdd1 is new hard disk in replace of /dev/sdc1
Then restore the vg metadata with following command
root# vgcfgrestore -f /etc/lvm/archive/vg0_0.vg tvg0
Note: check archive of vg in /etc/lvm/archive

How to restore accidently removed LVM


Following command can be helpful in this scenario
   vgcfgrestore
Also look at your /etc/lvm/archive/ for all archived metadata.
You should be able to use '--list' optio

Team multiple network interface into single interface /NIC Bonding

Team multiple network interface into single interface


Linux allows binding multiple network interfaces into a single channel/NIC using special kernel module called bonding.

Step #1: Create a bond0 configuration file

First, create bond0 config file in /etc/sysconfig/network-scripts/
# vi /etc/sysconfig/network-scripts/ifcfg-bond0Append 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


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

And do same for /etc/sysconfig/network-scripts/ifcfg-eth1

Step # 3: Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. One 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.

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/bond0Output:
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

Mysql Root Passwd Reset

root#mysqld_safe --skip-grant-tables&
Above command started mysqld daemon without grant tables, so no password will be asked if i need to go to mysql prompt
root#mysql
        mysql>use mysql
        mysql>update user set password=PASSWORD('abcd') where User='root'
        mysql>flush privileges
        mysql>quit