Pages

Monday, 23 June 2014

Rebuild initrd in Redhat Linux

Reference (Rebuild initrd and boot sequence): http://advancelinux.blogspot.ca/2013/06/how-to-rebuild-initrd-or-initramfs-in.html
 

What is initrd?

 The initial RAM disk (initrd) is an initial root file system that is mounted prior to when the real root file system is available. The initrd is bound to the kernel and loaded as part of the kernel boot procedure.

When do we need to rebuild initrd?
  • If adding new hardware to a system that may be used very early in the boot process.
  • If changing configuration files that may be used very early in the boot process
  • If changing the options on a kernel module.

How to rebuild initrd?

mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)

mkinitrd -f -v /boot/initrd-2.6.18-164.el5.img 2.6.18-164.el5

Kernel and initrd path in grub.conf

[root@localhost grub]# pwd
/boot/grub
[root@localhost grub]# cat grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-348.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-348.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet crashkernel=128M@16M
        initrd /initrd-2.6.18-348.el5.img

Wednesday, 11 June 2014

Mysql admin

Running mysql commands stored in a file without headers (Batch mode):

mysql --skip-column-names -h10.10.1.50 -u<username> -p < batch_file.txt

Execute mysql in one line,
mysql -u<user> -p -e "show processlist"

"show proceslist" shows you which threads are running. This statement is very useful if you get the too many connections error message and want to find out what is going on.

mysql> show FULL processlist; 
+-------+----------+---------------------+--------+---------+------+-------+-----------------------+
| Id    | User     | Host                | db     | Command | Time | State | Info                  |
+-------+----------+---------------------+--------+---------+------+-------+-----------------------+
| 20484 | User1 | localhost           | NULL   | Sleep   | 1381 |       | NULL                  |
| 20485 | User1 | 172.16.95.15:49580 | portal | Sleep   | 3056 |       | NULL                  |


mysql> show FULL processlist\G
*************************** 1. row ***************************
     Id: 20484
   User: user1
   Host: localhost
     db: NULL
Command: Sleep
   Time: 1414
  State:
   Info: NULL
*************************** 2. row ***************************
     Id: 20485
   User: user1
   Host: 172.16.95.15:49580
     db: portal
Command: Sleep
   Time: 3089
  State:
   Info: NULL