How do I find out Linux Disk utilization RHEL/Centos?

Wednesday, September 2nd, 2009

iostat syntax for disk utilization report

iostat -d -x interval count

-d : Display the device utilization report (d == disk)
-x : Display extended statistics including disk utilization

interval : It is time period in seconds between two samples . iostat 2 will give data at each 2 seconds interval.

count : It is the number of times the data is needed . iostat 2 5 will give data at 2 seconds interval 5 times

Display 3 reports of extended statistics at 5 second intervals for disk

Type the following command:

# iostat -d -x 5 3

Output:

[root@vari Desktop]# iostat -d -x 5 3

Linux 2.6.18-128.7.1.el5xen (vari.taashee.com) 08/26/2009 _i686_ (2 CPU)

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

sda 2.41 12.42 3.27 5.37 134.84 142.70 32.13 0.12 14.04 1.83 1.58

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

sda 0.00 1.60 0.00 0.40 0.00 16.00 40.00 0.00 0.00 0.00 0.00

Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

Where,

rrqm/s : The number of read requests merged per second that were queued to the hard disk
wrqm/s : The number of write requests merged per second that were queued to the hard disk
r/s : The number of read requests per second
w/s : The number of write requests per second
rsec/s : The number of sectors read from the hard disk per second
wsec/s : The number of sectors written to the hard disk per second
avgrq-sz : The average size (in sectors) of the requests that were issued to the device.
avgqu-sz : The average queue length of the requests that were issued to the device
await : The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.

svctm : The average service time (in milliseconds) for I/O requests that were issued to the device
%util : Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.

How do I interpret the output result for optimization?

First you need to note down following values from the iostat output:

1. The average service time (svctm)
2. Percentage of CPU time during which I/O requests were issued (%util)
3. See if a hard disk reports consistently high reads/writes (r/s and w/s)

If any one of these are high, you need to take one of the following action:

Get high speed disk and controller for file system (for example move from SATA I to SAS 15k disk)
Tune software or application or kernel or file system for better disk utilization
Use RAID array to spread the file system

cpio and rpm2cpio howto

Thursday, June 18th, 2009

To extract a cpio file:

cpio -iv < cpio_file

To list the contents of a cpio file:

cpio -itv < cpio_file

To create a cpio file with all files in the current directory:

ls | cpio -o > cpio_file

To extract all files from an RPM:

rpm2cpio RPM_file | cpio -idv

To extract individual file(s) from an RPM:

rpm2cpio RPM_file | cpio -id individual_file(s)

e.g. Extracting libcrypto.so.0.9.7a and libssl.so.0.9.7a from openssl-0.9.7a-2.i386.rpm:

rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -it egrep “libcrypto.so.0.9.7a|libssl.so.0.9.7a”

-rwxr-xr-x 1 root root 992092 Feb 27 12:10 ./lib/libcrypto.so.0.9.7a
-rwxr-xr-x 1 root root 216004 Feb 27 12:10 ./lib/libssl.so.0.9.7a

rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -idv ./lib/libssl.so.0.9.7a ./lib/libcrypto.so.0.9.7a

This will extract the two files from the RPM into a ./lib subdirectory.

Multiple gcc versions

Thursday, June 18th, 2009

Lets say you have this package from FC11:

[root@localhost ~]# rpm -q gcc
gcc-4.4.0-4.i586

But you have an source code that needs gcc-4.3 to compile or something lower.

So download lets say this: gcc-4.3.2-7.i386.rpm then:

mkdir newgcc && cd newgcc
download http://pathtogcc/gcc-4.3.2-7.i386.rpm
rpm2cpio gcc-4.3.2-7.i386.rpm | cpio -idv

Now you should have in newgcc/usr/bin/gcc.

Or download the gcc package you need from ftp://ftp.gnu.org and compile it with –prefix=$HOME/newgcc

Download RPMs with yum

Thursday, June 18th, 2009

Under Fedora and Centos:

[root@infra ~]# yum install yum-downloadonly

Be sure /etc/yum.conf contains : plugins=1

[root@infra ~]# yum reinstall gcc –downloadonly –downloaddir=/root
Loaded plugins: downloadonly
Setting up Reinstall Process
Resolving Dependencies
–> Running transaction check
—> Package gcc.i386 0:4.1.2-33 set to be updated
—> Package gcc.i386 0:4.1.2-33 set to be erased
–> Finished Dependency Resolution

Dependencies Resolved

Installing:
gcc i386 4.1.2-33 fedora 5.2 M
Removing:
gcc i386 4.1.2-33 installed 9.6 M

Transaction Summary

Install 1 Package(s)
Update 0 Package(s)
Remove 1 Package(s)

Total download size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
gcc-4.1.2-33.i386.rpm | 5.2 MB 00:00

exiting because –downloadonly specified

Now /root should contain : gcc-4.1.2-33.i386.rpm

Bandwidth Monitoring with Webmin

Wednesday, June 17th, 2009

I have Fedora 8 on this server..to install webmin:

yum -y install perl-Net-SSLeay
rpm -ihv http://superb-west.dl.sourceforge.net/sourceforge/webadmin/webmin-1.480-1.noarch.rpm

Then login to the Webmin interface: https://site.com:10000/ and enable Networking -> Bandwidth Monitoring.
It uses iptables and reads counters for IN/OUT. A good practice would be to change the port. This should work on Centos 5.2 / Centos 5.3 too. Also keep in mind that default installations of Fedora or Centos might require to open port 10000. On this Fedora 8 I had to :

iptables -I RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 10000 -j ACCEPT
service iptables save

How to upgrade MySQL 5.0 to MySQL 5.1 cPanel

Sunday, June 14th, 2009

How to upgrade MySQL 5.0 to MySQL 5.1 in a cPanel server

Login as root and edit /var/cpanel/cpanel.config.

Replace :

mysql-server=5.0 with
mysql-server=5.1

Finally run: /scripts/mysqlup

Xen howto create domU on Debian

Saturday, June 13th, 2009

Centos :

xen-create-image –lvm=lvm1 –hostname=hostname –install-method=rinse –dist=centos-5 –arch=amd64 –ip=ip –netmask=255.255.255.0 –gateway=gw –force –size=80Gb –swap=1024Mb –memory=1024

Debian:

xen-create-image –lvm=lvm1 –hostname=vm01 –install-method=debootstrap –arch=amd64 –ip=ip –netmask=255.255.255.0 –gateway=gw –force –size=80Gb –swap=1024Mb –memory=1024