Mezgani blog

November 8, 2009

Code names of Debian

Filed under: debian, informational — Tags: — Ali MEZGANI @ 1:18 am

When a Debian distribution is in the development stage, it has no version number but a codename. The purpose of these code names is to make easier the mirroring of the Debian distributions.
The code names of Debian releases are names of characters from the film Toy Story. The unstable, development distribution is permanently nicknamed sid, after the emotionally unstable next-door neighbor boy who regularly destroyed toys.

Code names of Debian

Code names of Debian

October 1, 2009

Howto setup IPMI under Linux (RHEL/CentOS 5) on the HP BL460c (Intel(R) Xeon(R) E5430)

Filed under: system — Tags: , , — Ali MEZGANI @ 12:23 pm

IPMI is a standardized message-based hardware management interface that provides a foundation for full monitoring of system health and management of the system, both locally and remotely in a secure manner.
The hardware chip that implements the core of IPMI is known as the Baseboard Management Controller (BMC), or Management Controller (MC).
And there are many companies that support IPMI. Dell, HP, Intel Corporation and NEC Corporation …

In our case and In practice, we will use the hp-OpenIPMI and hpasm drivers with RHEL/CentOS 5,
you must install the “kernel-devel” package and make sure its version matches the “kernel”
package you’re currently using. The “kernel-devel” package contains the necessary .config file for building kernel modules
(which is what the hp-OpenIPMI package wants to do).
$ sudo yum install kernel-devel

Fetch the HP OpenIPMI device drivers package and install it:
$ wget ftp://ftp.hp.com/pub/softlib2/software1/pubsw-linux/p402764200/v49065/hp-OpenIPMI-8.3.0-69.rhel5.i386.rpm
$ sudo rpm -ivh hp-OpenIPMI-8.3.0-69.rhel5.i386.rpm

The modules installed by the hp-OpenIPMI driver are :
ipmi_devintf.ko, ipmi_msghandler.ko, ipmi_poweroff.ko, ipmi_si.ko, ipmi_watchdog.ko

Install OpenIPMI the open source IPMI client:
$ sudo yum install OpenIPMI.i386

Create a patch file with this contenent:
$ cat > ipmi.patch

*** ipmi 2009-10-01 10:05:37.000000000 +0000
— /etc/init.d/ipmi 2009-09-30 10:53:20.000000000 +0000
***************
*** 335,341 ****
modprobe -q -r ${m} > /dev/null 2>&1
done
# delete interface node ONLY if ipmi_devintf is unloaded
! [ `lsmod | grep -c "ipmi_devintf"` -eq 0 ] &&
rm -f “/dev/ipmi${INTF_NUM}”
}

— 335,341 —-
modprobe -q -r ${m} > /dev/null 2>&1
done
# delete interface node ONLY if ipmi_devintf is unloaded
! [ `/sbin/lsmod | grep -c "ipmi_devintf"` -eq 0 ] &&
rm -f “/dev/ipmi${INTF_NUM}”
}

***************
*** 345,353 ****
modprobe -q -r ${m} > /dev/null 2>&1
done
# delete interface node ONLY if ipmi_devintf is unloaded
! [ `lsmod | grep -c "ipmi_devintf"` -eq 0 ] &&
rm -f “/dev/ipmi${INTF_NUM}”
! lsmod | egrep -q “ipmi_(poweroff|watchdog)” > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
stop_watchdog_quiet
stop_powercontrol_quiet
— 345,353 —-
modprobe -q -r ${m} > /dev/null 2>&1
done
# delete interface node ONLY if ipmi_devintf is unloaded
! [ `/sbin/lsmod | grep -c "ipmi_devintf"` -eq 0 ] &&
rm -f “/dev/ipmi${INTF_NUM}”
! /sbin/lsmod | egrep -q “ipmi_(poweroff|watchdog)” > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
stop_watchdog_quiet
stop_powercontrol_quiet
***************
*** 409,415 ****
— 409,424 —-

#############################################################################
start()
+
{
+ maj=`cat /proc/devices | awk ‘/ipmidev/{print $1}’`
+ if [ -c /dev/ipmi0 ]
+ then
+ rm -f /dev/ipmi0
+ /bin/mknod /dev/ipmi0 c $maj 0
+ else
+ /bin/mknod /dev/ipmi0 c $maj 0
+ fi
echo -n “Starting ${MODULE_NAME} drivers: “
load_ipmi_modules
if [ ${RETVAL} -eq 0 ]; then

To apply the patch to the ipmi file, change to the directory where the file is located:
$ cd /etc/init.d
$ sudo patch -p1 -i ~/ipmi.patch

Launch the IPMI service, which will load the kernel modules for you
$ sudo /etc/init.d/ipmi start

Fetch the HP System Health Application and Insight Management Agents package for Red Hat Enterprise Linux 5 (x86) like this:
$ wget ftp://ftp.hp.com/pub/softlib2/software1/pubsw-linux/p1925054526/v42992/hpasm-8.0.0-173.rhel5.i386.rpm
Let installed it with rpm and configure it before
$ sudo rpm -ivh hpasm-8.0.0-173.rhel5.i386.rpm
$ sudo /etc/init.d/hpasm configure

Start the hpasm agents using the command
$ sudo /etc/init.d/hpasm start

There are two ways to configure the BMC. You can configure it through the boot-time menu (Ctrl-E), where you can set the management password and IP address information. Or, you can configure it with ipmitool from the OS. We will configure it from OS so create a custom ipmi_lan.conf with this content
$ cat /etc/ipmi_lan.conf
addr 0.0.0.0
priv_limit admin
allowed_auths_callback md5
allowed_auths_user md5
allowed_auths_operator md5
allowed_auths_admin md5
user 2 true “username” “password” admin 1 md5

Start the ipmi daemon that will listen in all interfaces and will bind the 623 port by default.
$ sudo ipmilan -c /etc/ipmi_lan.conf

Add rule to the firewall if it’s running, this run tell to iptables to make the udp port 623 listening for connection coming from 192.168.0.18:
$ sudo vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state –state NEW -m udp -s 192.168.0.18 -p udp –dport 623 -j ACCEPT

Finally, to view the chassis status from a remote server, use the following command from your remote machine :
In this example from my Debian i do this :
$ ipmitool -I lan -U username -H 192.168.0.2 -a chassis status
Password:
System Power : on
Power Overload : false
Power Interlock : inactive
Main Power Fault : false
Power Control Fault : false
Power Restore Policy : always-on
Last Power Event :
Chassis Intrusion : inactive
Front-Panel Lockout : inactive
Drive Fault : false
Cooling/Fan Fault : false
Front Panel Control : none

Note the ‘-H’ option indicates the remote machine, ‘-U’ option parameter is the ‘userid’ name. The ‘-a’ option indicates to prompt for password.
This IPMItool command ‘chassis command’ result some information and the status of the machine’s system
Note that you cannot only get the status of the machine, you can also power it on and off, reset, adjust fan speeds etc …

For IPMI Problems please refer to https://twiki.cern.ch/twiki/bin/view/FIOgroup/IpmiPrb

September 17, 2009

Clone the same Debian packages from another target

Filed under: linux — Tags: , , — Ali MEZGANI @ 4:19 am

Sometimes we need to clone machines, for such use we may refer to rsync, and when we talk about debian package the debian package manager dpkg comes with some famous options that make our clone procedure very easy :
Let’s take an example :
So we have to clone the machine nibiru (machine to restore) from the machine maya (machine to backup):
Well On maya run:
$ sudo dpkg –get-selections > /tmp/dpkg.txt
Copy the dpkg.txt file to the target to restore system and run:
$ scp /tmp/dpkg.txt mezgani@nibiru:~/

On nibiru:
$ sudo dpkg –set-selections < ~/dpkg.txt
$ sudo apt-get -y update
$ sudo apt-get dselect-upgrade
et

September 2, 2009

How to find the PostgreSQL database size

Filed under: database — Tags: , , — Ali MEZGANI @ 1:49 am

PostgreSQL is a powerful, open source relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
If you want to find the size of a database, in our example the sqview database, please tape:
postgresql-300x10
sqview-# SELECT pg_database_size(’sqview’);
pg_database_size
——————
111415944
(1 ligne)

The result in octal, for a pretty print we will use the pg_size_pretty function which converts the size in bytes to human understandable format.
sqview-# SELECT pg_size_pretty(pg_database_size(’sqview’));
pg_size_pretty
—————-
106 MB
(1 ligne)

Well if we need to get the size of all databases
sqview-# SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;
datname | size
———–+———
postgres | 3537 kB
template1 | 3537 kB
template0 | 3480 kB
freedom | 25 MB
anakeen | 6081 kB
sqview | 106 MB
rt | 8201 kB
(7 lignes)

PostgreSQL can also give the size of a table ‘users’ like this

sqview-# SELECT pg_size_pretty(pg_relation_size(‘users’));
pg_size_pretty
—————-
64 kB
(1 ligne)

This value exclude indexes and some auxiliary data.
If you want to include them use pg_total_relation_size instead of pg_relation_size as shown below.
sqview-# SELECT pg_size_pretty(pg_total_relation_size(‘users’));
pg_size_pretty
—————-
152 kB
(1 ligne)

to find the largest table in the postgreSQL database.
sqview-# SELECT relname, relpages FROM pg_class ORDER BY relpages DESC limit 1;
relname | relpages
———+———-
sqview | 9666
(1 ligne)

Plotting CPU temperature with gnuplot

Filed under: linux, system, tools — Tags: , — Ali MEZGANI @ 12:59 am

Good sysadmins take a look daily to log, and they collect a lot of logs, the most of the information collected consists of time series data:
a set of numerical values associated with a sequence of discrete time values.
There are many number of tools for monitoring this data visually as it is collected, most of them are built using the exellent RRDTool, like cacti …
In this article, I’ll introduce you to Gnuplot, focusing specifically on how to plot time series data.
Gnuplot is a portable command-line driven interactive data and function plotting utility.
It has been supported and under development since 1986. Gnuplot supports many types of plots in either 2D and 3D.
It can draw using lines, points, boxes, contours, vector fields, surfaces, and various associated text. It also supports various specialized plot types.

Let’s start our example that is based on reading CPU Temperature Sensor.
We will use lm_sensor a hardware monitoring tool.
Create a cron entry that collect continuously the CPU temperature into a log file /var/log/sensors.log.
(echo `date +%b-%d-%H:%M:%S` | tr -d ‘\ 012′ ; echo -n ‘ ‘; sensors | awk ‘/CPU Temp:/{ print $3 }’ )>> /var/log/sensors.log

After create a file with this contents.
$ cat > temper.conf
set terminal png size 620,360
set xdata time
set timefmt “%b-%d-%H:%M:%S”
set output “temper.png”
# time range must be in same format as data file
set xrange ["AUG-25-00:00:00":"SEP-05-00:00:00"]
set yrange [0:60]
set grid
set xlabel “Date-Time”
set ylabel “°C”
set title “CPU temperature”
set key left box
plot “/var/log/sensors.log” using 1:2 index 0 title “aldebaran” with lines

Wait for a while for collecting data and tape the following command that will end up with a file called ‘temper.png’.
Use your favorite image viewer to take a look.
$ cat temper.conf | gnuplot

August 14, 2009

Monitoring Hard Disks with SMART on CentOS

Filed under: linux, system — Tags: , , — Ali MEZGANI @ 1:34 am

In this article i explain how to use smartmontools’ smartctl utility and smartd dæmon to monitor the health of a system’s disks. I have a HP server that come with a hard drive HP seagate DG072BB975 unfortunately that is not yet supported by hddtemp.
The server uses SAS (Serial Attached SCSI) HP drives, so the device is mounted in /dev/cciss/c0d0

First install smartmontools.
$ sudo yum install smartmontools

Looking to our partitions system.
$ cat /proc/partitions
major minor #blocks name

104 0 71652960 cciss/c0d0
104 1 104391 cciss/c0d0p1
104 2 71545477 cciss/c0d0p2
253 0 69500928 dm-0
253 1 2031616 dm-1
That appear that there some cciss (Compaq Smart Array Controller) interface good.

So, the HP server come with 2 disks and by default there are connected to the 0 and 1 channel.
first HDD is on -d cciss,0 and the second on the -d cciss,1

Well, to get smartctl working, you need to specify device/bus type and the disk number, like this:
$ sudo /usr/sbin/smartctl -H -d cciss,0 /dev/cciss/c0d0

smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

SMART Health Status: OK

this output shows the results of the health status inquiry. This is the one-line Executive Summary Report of disk health; the disk shown here has passed. If your disk health status is FAILING, back up your data immediately.
For a full report you can set the option –all like this:
$ sudo /usr/sbin/smartctl –all -d cciss,0 /dev/cciss/c0d0

smartctl version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

Device: HP DG072BB975 Version: HPDC
Serial number: 3NP3FWC200009917UFB3
Device type: disk
Transport protocol: SAS
Local Time is: Fri Aug 14 02:30:17 2009 GMT
Device supports SMART and is Enabled
Temperature Warning Enabled
SMART Health Status: OK

Current Drive Temperature: 26 C
Drive Trip Temperature: 68 C
Elements in grown defect list: 0
Vendor (Seagate) cache information
Blocks sent to initiator = 3368064691
Blocks received from initiator = 4000083366
Blocks read from cache and sent to initiator = 1897459483
Number of read and write commands whose size segment size = 0
Vendor (Seagate/Hitachi) factory information
number of hours powered up = 5259.38
number of minutes until next internal SMART test = 46

Error counter log:
Errors Corrected by Total Correction Gigabytes Total
ECC rereads/ errors algorithm processed uncorrected
fast | delayed rewrites corrected invocations [10^9 bytes] errors
read: 0 0 0 0 0 0.000 0
write: 0 0 0 0 0 0.000 0

Non-medium error count: 0
No self-tests have been logged
Long (extended) Self Test duration: 1070 seconds [17.8 minutes]

Configuring smartd:
Edit your smartd.conf file to add the disks you need. Ensure you edit the correct file (/etc/smartd.conf) and add the following lines:
$ cat >> etc/smartd.conf
/dev/cciss/c0d0 -d cciss,0 -H -m root@domain.tld
/dev/cciss/c0d0 -d cciss,1 -H -m root@domain.tld

Replace the email with your own so when a disk fails it will contact you directly.
and start smart daemon.
$ sudo /etc/init.d/smartd start

When you work on a group that runs a large computing cluster with many nodes and many disk drives, the use of SMART become very interesting really when it could help reduce downtime and keep the cluster operating more reliably.

August 11, 2009

Filesystems (jfs, xfs, ext3) comparison on Debian

Filed under: file system, linux, system — Tags: , — Ali MEZGANI @ 10:18 pm

File system is a method for storing and organizing computer files and the data they contain to make it easy to find and access them and there are a lot of type of file systems : shared file systems, database file systems, network file systems, disk file systems …
In Linux there are many disk file systems available, i felt the need to know more about some file systems performance on my old box, so i decided to do a benchmark essay.
In this studies we will look at the disk file systems and specially JFS (The IBM Journaled File System), XFS and ext3 (Third Extended File system).
This benchmark essay is based on some real-world tasks appropriate for a file server with older generation hardware (Pentium 4, IDE hard-drive).
I used an advanced automated tool named Bonnie++, a benchmark suite that is aimed at performing a number of simple tests of hard drive and file system performance. you can find more information about it at http://www.coker.com.au/bonnie++/

Description of Hardware used at tests:

processor : Intel(R) Pentium(R) 4 2xCPU 3.00GHz
RAM : 1287404 kB
Controller : 82801EB/ER (ICH5/ICH5R) IDE Controller
Hard drive:
$ sudo /usr/sbin/smartctl -i /dev/hdb

=== START OF INFORMATION SECTION ===
Model Family: Seagate Maxtor DiamondMax 20
Device Model: MAXTOR STM3802110A
Serial Number: 9LR4B9T3
Firmware Version: 3.AAJ
User Capacity: 80 026 361 856 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Sat Aug 8 19:10:53 2009 UTC
SMART support is: Available – device has SMART capability.
SMART support is: Enabled

OS:
$ cat /etc/issue; uname -a
Debian GNU/Linux squeeze/sid
Linux aldebaran 2.6.29 #2 SMP Thu Apr 2 20:37:46 UTC 2009 i686 GNU/Linux

All optional daemons killed (crond,sshd,httpd,…)
In this essay i used 3 partitions with 26GB for each one, the first partitions contains the jfs file systems the second contains the xfs file systems and the third contains ext3 file systems.

$ sudo parted /dev/hdb
GNU Parted 1.8.8
Using /dev/hdb
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) p
Model: MAXTOR STM3802110A (ide)
Disk /dev/hdb: 80,0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 17,4kB 26,0GB 26,0GB jfs jfs
2 26,0GB 52,0GB 26,0GB xfs xfs
3 52,0GB 78,0GB 26,0GB ext3 ext3

I install the file systems on each partition :

$ sudo jfs_mkfs /dev/hdb1
$ sudo mkfs.xfs /dev/hdb2
$ sudo mkfs.ext3 /dev/hdb3

I make directories and i mount them :
$ mkdir jfs xfs ext3
$ sudo mount /dev/hdb1 jfs/
$ sudo mount /dev/hdb2 xfs/
$ sudo mount /dev/hdb3 ext3/

Later i rund bonnie++ this :
$ for i in *; do sudo /usr/sbin/bonnie++ -u 1000:1000 -d `pwd`/$i -q > $i.csv ; sleep 20; done
sleeping time is for freeing the busy resources, thanks bortzmyer for the tips :)
And i get this great result detailed

fs

We can see that there are not big difference between these filesystem, even JFS is useless of cpu and has better output/intput usage.
JFS may not have been marketed as effectively as other alternatives, but is a solid choice in the long list of quality Linux filesystems.

Facebook scale

Filed under: informational — Tags: , — Ali MEZGANI @ 5:00 pm

One of the disadvantages of having a big contact list into facebook, is that you lose many friend’s posts, you spend much time to read or watch all interesting posts, and also consecrating a lot of times to facebook, and i think that is not really good.
Anyway, i see facebook merging to a mini youtube or a social youtube when 70% of facebook traffic is sharing video.

How to setup GFS on RHEL/CentOS/Fedora

Filed under: file system — Tags: , , , — Ali MEZGANI @ 9:25 am

A clustered file system or SAN file system, is an enterprise storage file system which can be shared (concurrently accessed for reading and writing) by multiple computers. Such devices are usually clustered servers, which connect to the underlying block device over an external storage device. Such a device is commonly a storage area network (SAN).
Examples of such file systems:
* GFS : The Red Hat Global File System
* GPFS : IBM General Parallel File System
* QFS : The Sun Quick File System
* OCFS : Oracle cluster file system
In the rest of tutorial we will focus on GFS2 file system the new version of GFS file system, and how to mount a shared disk on a Fedora, Red Hat or CentOS. GFS (Global File System) is a cluster file system. It allows a cluster of computers to simultaneously use a block device that is shared between them (with FC, iSCSI, NBD, etc…). GFS is a free software, distributed under the terms of the GNU General Public License, was originally developed as part of a thesis-project at the University of Minnesota in 1997.
So, let start this brief configuration.
First install utilities for managing the global filesystem (GFS)
[mezgani@troy ~]$ sudo yum install gfs2-utils
You may use parted to manage partitions on sda disk, and create some partitions.
Parted is an industrial-strength package for creating, destroying, resizing, checking and copying partitions, and the file systems on them. It support big partitions unlike fdisk.
For example here i create a partition of 1T.
[mezgani@troy ~]$ sudo parted /dev/sda
GNU Parted 1.8.1
On utilise /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) p

Model: HP MSA2012fc (scsi)
Disk /dev/sda: 2400GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Fanions
2 1001GB 2400GB 1399GB ext3 primary

(parted) mkpart primary
Type de système de fichiers? [ext2]? ext3
Début? 0
Fin? 1001GB
(parted) print

Model: HP MSA2012fc (scsi)
Disk /dev/sda: 2400GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Fanions
1 17,4kB 1001GB 1001GB ext3 primary
(parted) quit

After creating partition, make gfs2 file system on it, with mkfs.gfs2 like this
[mezgani@troy ~]$ sudo /sbin/mkfs.gfs2 -p lock_dlm -t alpha:gfs2 -j 8 /dev/sda1
This will destroy any data on /dev/sda1.
It appears to contain a ext3 filesystem.

Are you sure you want to proceed? [y/n] y

Device: /dev/sda1
Blocksize: 4096
Device Size 932.25 GB (244384761 blocks)
Filesystem Size: 932.25 GB (244384760 blocks)
Journals: 8
Resource Groups: 3730
Locking Protocol: “lock_dlm”
Lock Table: “alpha:gfs2″

Last, make a directory and mount our gfs file system on it.
[mezgani@troy ~]$ sudo mkdir /home/disk
[mezgani@troy ~]$ sudo mount -o acl -t gfs2 /dev/sda1 /home/disk

However, if a storage device loses power or is physically disconnected, file system corruption may occur.
Well, you can recover the GFS2 file system by using the gfs_fsck command.

[mezgani@troy ~]$ sudo fsck.gfs2 -v -y /dev/sda1
With the -y flag specified, the fsck.gfs2 command does not prompt you for an answer before making changes.

August 2, 2009

Pipes in syslog

Filed under: bash, linux, system — Tags: — Ali MEZGANI @ 11:30 pm

Using syslog, there are a possiblity to write the output to a pipe, so we can read this pipe from a program. But we have to be careful, syslogd should not wedge but we will have missing and/or mangled
messages if they arrive faster than our program can process them.
Let’s take look to how to create these pipes and read from them:

First create a named pipe using mkfifo:
$ mkfifo -p /home/mezgani/syslog.pipe

Make syslog.conf to points to this file:
*.info |/home/mezgani/syslog.pipe

Restart syslog:
$ sudo pkill -HUP syslogd

Create processing script that read the pipe
$ cat > foo
#!/bin/bash
cat /home/mezgani/syslog.pipe | while read input
do
# some stuff
echo ${input}
# ….
done

Older Posts »

Blog at WordPress.com.