Sunday, March 25, 2012

Step by Step: Adding a Netapp LUN to VMware vCenter.

In this series we have added a LUN to a Netapp Filer, and 

In this Step by Step part, we will add the storage we added in the previous article and make it accessible to vCenter.

Step 1:

Open up vCenter using vSphere:

Click on the host that you want to add the storage to, and then on the configuration tab:

Next click on "Storage"

And as you can see, there are various types of storage there, some are LUNs coming from a NetApp, and others are NFS exports, also exported by the NetApp filer.

Then click on "Rescan All" and you will get this popup confirmation, and click on "Ok"

You will get a message on the bottom of the screen that it's rescanning:

Now click on "Add Storage" and you will get this window:

You should then see your newly created LUN in the window:

Highlight this line, and click next (will be un-greyed when you choose the LUN)  You then get this screen below:

You will then be asked to name your datastore:

After that, you will be asked to choose the Maximum block size:

In our case it's not applicable, as our whole space is smaller than 256Gb. so we choose 1Mb/256Gb

You will then get a summary screen like below:

After you click Finish, you can then see the storage was added:

Now, you can add it to any VM's or use like any other storage on the system, for example. adding space to a VM:

Choose: Hard Disk

Create a New Virtual Disk:

We'll make it 16Gb for demo purposes:

You have to click on "Specify a Datastore" below, and choose our newly created storage:

Click on Next for the next screen unless you need special options for the virtual device node, you can select which SCSI device identifier to use for the drive. For example, if you select SCSI 0:2, the guest operating system recognizes the drive as ID 2 on controller 0.

You also have an unchecked option there to select the virtual disk Independent mode and select an option.

The disk operates normally except that changes to the disk are permanent even if the virtual machine is reverted to a snapshot.
The disk appears to operate normally, but whenever the virtual machine is powered off or reverted to a snapshot, the contents of the disk return to their original state. All later changes are discarded.
Independent disks are not affected by snapshots.

Finally when you click on Finish, you will get this screen:

 This is it, now you have a new 16Gb "disk" on the system.

In the next article, we will do a step by step on actually using that space on the underlying Linux System!

Adding SCSI Storage to a Redhat or CentOS without Rebooting

In today's post, we will add the storage we added on the NetApp to the actual machine for usage. 
This storage is coming through the vCenter VMware system (as in the post about adding that storage) and not directly through NFS.

1.  First off log into your Linux box, and SU to root

2.  Then issue a rescan command to the hosts you have:

ls /sys/class/scsi_host

host0 host1 host2

 We will then issue a rescan for all 3:

 echo "- - -" > /sys/class/scsi_host/host0/scan
 echo "- - -" > /sys/class/scsi_host/host1/scan
 echo "- - -" > /sys/class/scsi_host/host2/scan

Then issue a "fdisk -l"

You should see message such as this below:

[root@cent01 ~]# tail /var/log/messages
Mar 26 10:45:56 cent01 kernel: sd 0:0:1:0: [sdb] Assuming drive cache: write through
Mar 26 10:45:56 cent01 kernel: sdb: sdb1
Mar 26 10:47:03 cent01 kernel: kjournald starting.  Commit interval 5 seconds
Mar 26 10:47:03 cent01 kernel: EXT3 FS on sdb1, internal journal
Mar 26 10:47:03 cent01 kernel: EXT3-fs: mounted filesystem with ordered data mode.
Mar 26 10:54:39 cent01 kernel: ata1: soft resetting link
Mar 26 10:54:39 cent01 kernel: ata1: EH complete
Mar 26 10:54:42 cent01 kernel: ata2: soft resetting link
Mar 26 10:54:42 cent01 kernel: ata2.00: configured for UDMA/33
Mar 26 10:54:42 cent01 kernel: ata2: EH complete
[root@cent01 ~]#

You can also look at the output of "fdisk -l" and see the following:

Disk /dev/sdb: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

So our new Disk has been assigned /dev/sdb

Now we have to partition it, and put a filesystem on it:

we will do the following:

fdisk /dev/sdb
then go through the prompts and create a partition for the whole 17Gb virtual disk:

after the partition has been created, now format it with ext3 filesystem:

mkfs.ext3 /dev/sdb1

As you can see by the screenshot above, the partition was formatted, we will now 
create a mount point:

mkdir /extra16Gb

and then mount this device on this mount point:

mount /dev/sdb1  /extra16Gb/

You can see that we can create a file on the new mountpoint, and that it has the expected space on it.

One last thing, is to add this to /etc/fstab, as when this machine will reboot, you want this new disk mounted at boot time.  So we will edit /etc/fstab and add
this disk:

You can test if this works by unmounting the device:

[root@cent01 ~]# umount /extra16Gb/

and do a mount all:

[root@cent01 ~]# mount -a
[root@cent01 ~]#

Then see if this new device is now mounted:

[root@cent01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       15G  9.6G  4.1G  71% /
tmpfs                 2.9G   76K  2.9G   1% /dev/shm
/dev/sda1             485M   44M  417M  10% /boot
                       50G   44G  7.0G  87% /opt2
/dev/sdb1              16G  173M   15G   2% /extra16Gb

[root@cent01 ~]#

And as you can see, it's showing up correctly.  The VMware guest now has an additional virtualized storage device. The works for all physical block devices, this includes CD-ROM, DVD and floppy devices.

Friday, March 23, 2012

RedHat: verify loaded kernel module options

How can you check the options on loaded kernel modules in RedHat Linux?
For example, we have a qla2xxx kernel module loaded into the kernel i.e.

[root@server1 proc]# lsmod |grep qla2xxx
qla2xxx              1019552  235
qla2xxx_conf          310408  1
scsi_mod              152465  7

In modprobe.conf we have following options for qla2xxx module:

[root@server1 proc]# grep options /etc/modprobe.conf|grep -v bond0
options qla2xxx qlport_down_retry=1 ql2xfailover=0 ConfigRequired=0
You can check the module parameters in 
So, for example with qla2xxx :
# cat /sys/module/qla2xxx/parameters/
ql2xallocfwdump             ql2xenablemsix              ql2xfdmienable    
ql2xlogintimeout            ql2xplogiabsentdevice      
ql2xqfulltracking           ql2xdevdiscgoldfw          
ql2xextended_error_logging  ql2xloginretrycount         ql2xmaxqdepth  
ql2xqfullrampup             qlport_down_retry        
Note: not all modules expose their parameters to the /sys tree. 
eq, the bnx2 module.

Wednesday, March 21, 2012

Cluster SSH tool

Nifty little tool I came across, will allow you to administer multiple machines from one console.... check it out at

This was done on my virtual Mac on a VMware workstation on which I also installed Cisco AnyConnect client which connected to the Cisco ASA5540 Firewall, behind which these VM's sit.

To make a long story short, just copy the perl script to /usr/bin or anywhere in your path, 
and then execute as such:

# csshx -l username

in the case above, it will pass an ssh username of "username" and open up 4 terminals, as in the picture above.

You input your command in the red area underneath the terminals, and it will duplicate to all the other terminals.  watch out for mistakes!

Thursday, March 1, 2012

How to Compile and Install Memcached

How to Compile and Install Memcached

Prerequisites:  libevent and memcached source code

Version: libevent 2.0.10, memcached 1.4.5

Memcached file download:

Summary: This guide outlines the steps required to build and install a memcached server.

  1. Create a directory to store your source files.

mkdir -p ~/source

  1. Download the libevent source code to ~/source

  1. Expand the libevent source archive.

cd ~/source; tar xzf libevent-2.0.10-stable.tar.gz

  1. Run the configure script with the following options.

cd  ~/source/libevent-2.0.10-stable

./configure --prefix=/opt/apps/libevent \

  1. Compile and install libevent

make install

  1. Reconfigure the run-time link bindings to include the libevent shared libraries

echo /opt/apps/libevent/lib > /etc/

  1. Download the memcached source code to ~/source

  1. Expand the memcached source archive.

cd ~source; tar xzf memcached-1.4.5.tar.gz

  1. Run the configure script with the following options.

./configure --prefix=/opt/apps/memcached \
--with-libevent=/opt/apps/libevent \

  1. Compile and install memcached

make install

cp ~/source/memcached-1.4.5/scripts/memcached-tool /opt/apps/memcached/bin/

  1. Create required memcached files/directories.

mkdir -p /opt/apps/memcached/conf
mkdir -p /opt/apps/memcached/init
mkdir -p /var/run/memcached
touch /var/lock/subsys/memcached

  1. Create a new configuration file /opt/apps/memcached/conf/memcached.conf. A sample can be seen here:
# max connection 2048
# set ram size to 2048 - 2GiB
# listen to loopback ip, for network connection use real ip e.g.,
OPTIONS="-l whatever-app"

  1. Create the memcached init script /opt/apps/memcached/init/memcached.init and configure it to run on system startup. A sample copy can be seen below.  Modify the file accordingly to fit your site’s needs.

#! /bin/sh
# chkconfig: - 55 45
# description:  The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached

# Source function library.
. /etc/rc.d/init.d/functions


#if [ -f /etc/sysconfig/memcached ];then
#    . /etc/sysconfig/memcached

if [ -f /opt/apps/memcached/conf/memcached.conf ];then
    . /opt/apps/memcached/conf/memcached.conf

# Check that networking is up.
if [ "$NETWORKING" = "no" ]
    exit 0


start () {
    echo -n $"Starting $prog: "
    # insure that /var/run/memcached has proper permissions
    chown $USER /var/run/memcached
    $prog -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/ $OPTIONS
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
stop () {
    echo -n $"Stopping $prog: "
    killproc memcached
    if [ $RETVAL -eq 0 ] ; then
        rm -f /var/lock/subsys/memcached
        rm -f /var/run/

restart () {

# See how we were called.
case "$1" in
    status memcached
    [ -f /var/lock/subsys/memcached ] && restart || :
    echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
    exit 1

exit $?

ln -s /opt/apps/memcached/init/memcached.init /etc/init.d/memcached

 chkconfig memcached on

  1. Verify memcached is configured to start up automatically upon system reboot.

# chkconfig --list memcached
memcached       0:off   1:off   2:on    3:on    4:on    5:on    6:off

  1. Start the memcached server.

/etc/init.d/memcached start

  1. Useful commands. Replace <host-ip> with the address memcached is bound to. <memcached-port> is the port memcached is listening on.

Display memcached slabs:
/opt/apps/memcached/bin/memcached-tool <host-ip>:<memcached-port> display

Display memcached general stats:
/opt/apps/memcached/bin/memcached-tool <host-ip>:<memcached-port> stats

Display memcached  keys and values:
/opt/apps/memcached/bin/memcached-tool <host-ip>:<memcached-port> dump