lost and found ( for me ? )

install dnsperf 2.0 on Linux Mint 12


dnsperf is DNS stressing tool provide by Nominum.

You can get it from the following URL.
http://www.nominum.com/resources/measurement-tools

As for RHEL , there are RPM packages for RHEL4 i386 , RHEL 5 i386 , RHEL6 x86 64.
As for Debian based , there are no deb packages.
I’ll install this on Linux Mint 12 from the source.
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"

# uname -ri
3.0.0-17-generic x86_64


download the source
dnsperf-src-2.0.0.0-1.tar.gz
# tar xzvf dnsperf-src-2.0.0.0-1.tar.gz
# cd dnsperf-src-2.0.0.0-1/


Seen from README , BIND 9.4.0 or greater need to be installed to compile dnsperf 2.0
1. Make sure that BIND 9 (9.4.0 or greater) is installed, including libraries
  and header files, and that the isc-config.sh program distributed with BIND
  is in your path.


Befre installing dnsperf 2.0 , I’ll install BIND 9.9.0
# tar xzvf bind-9.9.0.tar.gz bind-9.9.0/
# cd bind-9.9.0/
# ./configure
# make
# make install
# /usr/local/sbin/named -V
BIND 9.9.0 built with defaults
using OpenSSL version: OpenSSL 1.0.0e 6 Sep 2011


install dnsperf 2.0
# cd dnsperf-src-2.0.0.0-1/
# sh configure


nnn , error .. there’s no hmacsha.h: ..
# make
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c dnsperf.c
dnsperf.c: In function ‘main’:
dnsperf.c:1041:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
dnsperf.c: In function ‘do_send’:
dnsperf.c:668:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
dnsperf.c: In function ‘handle_sigint’:
dnsperf.c:197:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c datafile.c
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c dns.c
dns.c:46:25: fatal error: isc/hmacsha.h: No such file or directory
compilation terminated.
make: *** [dns.o] Error 1


Senn from README , it describes that:
Note: many versions of bind do not correctly install the <isc/hmacsha.h>
  header file, so if the compilation fails, obtain this file from the BIND
  source distribution, and install it in the appropriate place.


where is hmacsha.h …
# locate hmacsha.h
/home/zzz/my_works/bind-9.9.0/lib/isc/include/isc/hmacsha.h


and which directory should I put it ??

under /usr/local/include/isc directory ?
# ls /usr/local/include/isc/
app.h            hex.h            netaddr.h        sha2.h
assertions.h     hmacmd5.h        netdb.h          sockaddr.h
atomic.h         httpd.h          offset.h         socket.h
base64.h         int.h            once.h           stdio.h


copy hmacsha.c to /usr/local/include/isc directory.
# cp /home/zzz/my_works/bind-9.9.0/lib/isc/include/isc/hmacsha.h /usr/local/include/isc


try again
# sh configure


okay.
# make
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c dns.c
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c log.c
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c net.c
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c opt.c
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c os.c
ar rv libperf.a datafile.o dns.o log.o net.o opt.o os.o
ar: creating libperf.a
a - datafile.o
a - dns.o
a - log.o
a - net.o
a - opt.o
a - os.o
ranlib libperf.a
gcc -pthread dnsperf.o  libperf.a -lnsl  -L/usr/local/lib -lbind9 -ldns -lcrypto -lisccfg -lisc -ldl  -lm -o dnsperf
gcc -g -O2 -I/usr/local/include -D_GNU_SOURCE -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_PTHREAD=1 -pthread -c resperf.c
gcc -pthread resperf.o  libperf.a -lnsl  -L/usr/local/lib -lbind9 -ldns -lcrypto -lisccfg -lisc -ldl  -lm -o resperf
#

# make install
mkdir -p /usr/local/bin
mkdir -p /usr/local/share/man/man1
/usr/bin/install -c  dnsperf /usr/local/bin
/usr/bin/install -c  resperf /usr/local/bin
/usr/bin/install -c  resperf-report /usr/local/bin
/usr/bin/install -c -m 644  dnsperf.1 /usr/local/share/man/man1
/usr/bin/install -c -m 644  resperf.1 /usr/local/share/man/man1


get things done :)
# ls /usr/local/bin/*perf
/usr/local/bin/dnsperf  /usr/local/bin/resperf

Small tips : How find/kill zombie processes


There are many ways to find out zombie processes , so this is one of examples.
# cat /etc/centos-release
CentOS release 6.2 (Final)

find zombie processes
# top -b -n 1 | grep Z
6072 root      20   0     0    0    0 Z  0.0  0.0   0:00.09 dumpcap <defunct>
6075 root      20   0     0    0    0 Z  0.0  0.0   0:00.11 dumpcap <defunct>

or
#  ps aux | awk '{ print $8 " " $2 }' | grep -w Z
Z 6072
Z 6075

kill zombie processes
# kill -9 6072
# kill -9 6075

how to install CentOS 6 via USB stick


At first , I made an installation USB stick for CentOS6 with unetbootin tool on Linux Mint 12 machine , however I can’t install CentOS6 via that USB stick created by unetbootin
unetbootin does not seem to support CentOS 6 as of now…

I could install CentOS 6 via USB stick by following instructions.
many tnx !

there are two ways to make an installation USB stick
- use CentOS iso
- use CentOS Live iso

the latter is easier. ( IMO )

[ use CentOS iso ]

download iso
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"

# uname -ri
3.0.0-16-generic x86_64

# ls *.iso
CentOS-6.2-x86_64-bin-DVD1.iso  CentOS-6.2-x86_64-bin-DVD2.iso


make two partitions.
200MB for vfat and the other is for ext3.
# LANG=C fdisk /dev/sdd

Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4, default 1): 1
First sector (2048-15826943, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15826943, default 15826943): +200M

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4, default 2): 2
First sector (411648-15826943, default 411648):
Using default value 411648
Last sector, +sectors or +size{K,M,G} (411648-15826943, default 15826943):
Using default value 15826943

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sdd: 8103 MB, 8103395328 bytes
250 heads, 62 sectors/track, 1021 cylinders, total 15826944 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6b8b4567

  Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *        2048      411647      204800    b  W95 FAT32
/dev/sdd2          411648    15826943     7707648   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.


make filesystem
# mkfs.vfat -n boot /dev/sdd1
# mkfs.ext3 -m 0 -b 4096 -L data /dev/sdd2


make directores and mount iso
# mkdir /mnt/USB
# mkdir /mnt/DVD
# mount -t iso9660 -o loop CentOS-6.2-x86_64-bin-DVD1.iso /mnt/DVD/
# mount /dev/sdd2 /mnt/USB/

# cp -r /mnt/DVD/images /mnt/USB
`# cp -r CentOS-6.2-x86_64-bin-DVD*.iso /mnt/USB
# umount /mnt/USB


install MBR , syslinux etc
# apt-get install syslinux –y

# locate mbr.bin
/usr/lib/syslinux/altmbr.bin
/usr/lib/syslinux/gptmbr.bin
/usr/lib/syslinux/mbr.bin

# dd if=/usr/lib/syslinux/mbr.bin of=/dev/sdd
# syslinux -sddv/sdd1
# mkdir /mnt/BOOT
# mount /dev/sdd1 /mnt/BOOT/

# cp /mnt/DVD/isolinux/isolinux.bin /mnt/BOOT/syslinux.bin
# cp /mnt/DVD/isolinux/isolinux.cfg /mnt/BOOT/syslinux.cfg

# cp /mnt/DVD/isolinux/vmlinuz /mnt/BOOT/
# cp /mnt/DVD/isolinux/initrd.img /mnt/BOOT/



edit syslinux.cfg like this
# cat /mnt/BOOT/syslinux.cfg
default CentOS
prompt 0

label CentOS
       kernel vmlinuz
       append initrd=initrd.img method=hd:sdc2:/

the line “method=hd … “ dpends on your environment. ( sda2 or sdd2 or sdc2 )
In my case , I could install CentOs6 when specifying sdc2.
( there are two HDDs have been installed in my PC )
# umount /mnt/BOOT
# umount /mnt/DVD


get things done.
install CentOS6 by using that USB stick.

[ use CentOS Live iso ]

You can install CentOS6 using CentOS Live version.

download CentOS live CD and do the following command.
# LANG=C fdisk /dev/sdd

Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4, default 1): 1
First sector (2048-15826943, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-15826943, default 15826943):
Using default value 15826943

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

# dd if=CentOS-6.2-x86_64-LiveCD.iso of=/dev/sdd bs=1M


Boot CentOS6 Live via the USB stick and then select “install” from the boot menu to install CentOS6 on your HDD.

KVM : add a storage to running VMs by “virsh attach-disk” command



# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Linux Mint 12 Lisa"
# uname -ri
3.0.0-16-generic x86_64

# libvirtd --version
libvirtd (libvirt) 0.9.2

# virt-manager --version
0.9.0

# kvm --version
QEMU emulator version 0.14.1 (qemu-kvm-0.14.1), Copyright (c) 2003-2008 Fabrice Bellard


start a VM ( this VM is openfiler 2.99 )
virsh # start filer01


The VM , fieler01 , has three storage devices , sda , sdb and sdc.
[root@filer01 ~]# dmesg | grep sd[a-z] | grep -i attach
sd 0:0:0:0: [sda] Attached SCSI disk
sd 0:0:1:0: [sdb] Attached SCSI disk
sd 1:0:1:0: [sdc] Attached SCSI disk


add one more storage via virsh

on the KVM host , create a storage file for that VM
# qemu-img create -f raw filer01-data1.img 1G


on the KVM host , add that storage as “/dev/sdd” to that running VM
virsh # attach-disk --driver file filer01 /var/disk1/libvirt/images/filer01-data1.img sdd
error: Failed to attach disk
error: internal error unsupported driver name 'file' for disk '/var/disk1/libvirt/images/filer01-data1.img'


nnn , error ,,

Let’s check libvirt.log.

/var/log/libvirt/libvirtd.log
error : qemuDomainAttachDeviceDiskLive:3994 : internal error unsupported driver name 'file' for disk '/var/disk1/libvirt/images/filer01-data1.img'


nnnn , I’m not familiar with virsh command…

How about this ?
virsh # attach-disk filer01 /var/disk1/libvirt/images/filer01-data1.img sdd --type disk
Disk attached successfully


I could add the storage ( /dev/sdd )
[root@filer01 ~]# dmesg | grep sd[a-z] | grep -i attach
sd 0:0:0:0: [sda] Attached SCSI disk
sd 0:0:1:0: [sdb] Attached SCSI disk
sd 1:0:1:0: [sdc] Attached SCSI disk
sd 2:0:3:0: [sdd] Attached SCSI disk


The following is an excerpt of xml file of the VM to which I added a storage via virsh attach-disk
   <disk type='block' device='disk'>
     <driver name='qemu' type='raw'/>
     <source dev='/var/disk1/libvirt/images/filer01-data1.img'/>
     <target dev='sdd' bus='scsi'/>
     <alias name='scsi0-0-3'/>
     <address type='drive' controller='0' bus='0' unit='3'/>
   </disk>


The following is via virt-manager
   <disk type='file' device='disk'>
     <driver name='qemu' type='raw'/>
     <source file='/var/disk1/libvirt/images/filer01-data.img'/>
     <target dev='hdd' bus='ide'/>
     <alias name='ide0-1-1'/>
     <address type='drive' controller='0' bus='1' unit='1'/>
   </disk>


let’s create a partition on /dev/sdd

warning … partition table is GPT …
[root@filer01 ~]# fdisk /dev/sdd

WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.


change the partition table to msdos from gpt
[root@filer01 ~]# parted /dev/sdd
GNU Parted 1.8.8
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
Warning: The existing disk label on /dev/sdd will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? Yes
New disk label type?  [gpt]? msdos
(parted) quit
Information: You may need to update /etc/fstab.


Ok , no warning message
[root@filer01 ~]# fdisk /dev/sdd

Command (m for help): q

[root@filer01 ~]#