rageek

A place for Unix Thoughts and Ideas

Monthly Archives: December 2010

Show SAN Target information for HBA’s on a Solaris system

Here is a quick 1-liner for displaying all the Targets and LUNs that are seen by all the HBA’s on a Solaris System

fcinfo hba-port | grep ‘Port WWN’ | awk ‘{print $4}’ | xargs -i sh -c ” echo HBA {}; fcinfo remote-port -sl -p {}”

This outputs the following (note: the space formatting seems to be lost in the posting)

Read more of this post

Advertisements

Displaying Zone resource utilization on Solaris 10 with zonestat

A while back I discovered the extremely useful zonestat script for giving dashboard view of the resource utilization across all zones in a system.

Here is a sample of the output from one of our M4k hosting some Oracle zones.

root@testserver # /admin/zonestat_1.4.1.pl -Nl
            |----Pool-----|------CPU-------|----------------Memory----------------|
            |---|--Size---|-----Pset-------|---RAM---|---Shm---|---Lkd---|---VM---|
Zonename    | IT| Max| Cur| Cap|Used|Shr|S%| Cap|Used| Cap|Used| Cap|Used| Cap|Used
-----------------------------------------------------------------------------------
    global    0D        32  0.0  0.6   1 25      252M  18E 121K  18E 3.2M  18E 808M
orazone-01    0D        32  0.0  0.0   1 25       21G  18E  0.0  18E  21G  18E  23G
orazone-02    0D        32  0.0  1.9   1 25       26G  18E  0.0  18E  26G  18E  29G
orazone-03    0D        32  0.0  2.2   1 25       22G  18E  0.0  18E  19G  18E  25G
==TOTAL===== --- ----   32 ----  4.8 --- -- 103G  90G 103G  67G 103G  65G 103G  78G

The VirtualMemory fields is extremely useful on systems which host java applications, as they tend to reserves huge amounts of VM while having a relatively small RSS.

This is usually one of the first utilities I run if I’m trying to track down a memory/swap or cpu issue on a global zone.

It was written by Jeff Victor and unfortunately the project page is gone.

However, I have posted a copy for download here

4/11/2013 – Updated with new link for zonestat script.

List all Storage with Size on Solaris

Here is a quick one liner for listing all the storage configured in server and the size of the storage

It prints out the size in GB and MB, which is handy for my small LUNs which are using for fencing.

for c in $(iostat -En | grep Soft | awk ‘{print $1}’ | cut -d t -f1 | sort | uniq); do for i in `iostat -En | grep Soft | awk ‘{print $1}’ | grep “$c”`;do SZ=$(iostat -En $i | grep Size | cut -d'<‘ -f2); echo “$i ${SZ%% *}” | awk ‘{printf ( “%s %2d GB ( %d MB)\n”, $1, $2/1024/1024/1024+.05, $2/1024/1024+.05) }’; done | sort -t d +1 -n; done

Here is the output from a T5120 in a RAC cluster.

root@testserver # for c in $(iostat -En | grep Soft | awk ‘{print $1}’ | cut -d t -f1 | sort | uniq); do for i in `iostat -En | grep Soft | awk ‘{print $1}’ | grep “$c”`;do SZ=$(iostat -En $i | grep Size | cut -d'<‘ -f2); echo “$i ${SZ%% *}” | awk ‘{printf ( “%s %2d GB ( %d MB)\n”, $1, $2/1024/1024/1024+.05, $2/1024/1024+.05) }’; done | sort -t d +1 -n; done
c0t0d0 0 GB ( 0 MB)
c1t0d0 136 GB ( 140009 MB)
c1t1d0 136 GB ( 140009 MB)
c2t50060E800547725Dd0 0 GB ( 90 MB)
c2t50060E800547725Dd1 0 GB ( 90 MB)
c2t50060E800547725Dd2 0 GB ( 90 MB)
c2t50060E800547725Dd3 0 GB ( 500 MB)
c2t50060E800547725Dd4 50 GB ( 51200 MB)
c2t50060E800547725Dd5 10 GB ( 10240 MB)
c2t50060E800547725Dd6 10 GB ( 10240 MB)
c2t50060E800547725Dd7 50 GB ( 51200 MB)
c2t50060E800547725Dd8 500 GB ( 512000 MB)
c2t50060E800547725Dd9 10 GB ( 10240 MB)
c2t50060E800547725Dd10 10 GB ( 10240 MB)
c2t50060E800547725Dd11 1023 GB ( 1048000 MB)
c3t50060E800547724Dd0 0 GB ( 90 MB)
c3t50060E800547724Dd1 0 GB ( 90 MB)
c3t50060E800547724Dd2 0 GB ( 90 MB)
c3t50060E800547724Dd3 0 GB ( 500 MB)
c3t50060E800547724Dd4 50 GB ( 51200 MB)
c3t50060E800547724Dd5 10 GB ( 10240 MB)
c3t50060E800547724Dd6 10 GB ( 10240 MB)
c3t50060E800547724Dd7 50 GB ( 51200 MB)
c3t50060E800547724Dd8 500 GB ( 512000 MB)
c3t50060E800547724Dd9 10 GB ( 10240 MB)
c3t50060E800547724Dd10 10 GB ( 10240 MB)
c3t50060E800547724Dd11 1023 GB ( 1048000 MB)

Accessing Solaris 11 contract support repositories

Solaris 11 now uses repositories instead of the old recommended patch bundles.

With Oracle locking down access, here is how to configure access, if you have a current Support contract.

  1. 1. Go to https://pkg-register.oracle.com/ and login with your Oracle Support ID.
  2. 2. Generate your support key and certificate and save/transfer them to your Solaris 11 server.
  3. 3. On the server do the following:

sudo mkdir -m 0755 -p /var/pkg/ssl
sudo cp -i /var/tmp/Oracle_Solaris_11_Express_Support.key.pem /var/pkg/ssl
sudo cp -i /var/tmpOracle_Solaris_11_Express_Support.certificate.pem /var/pkg/ssl

sudo pkg set-publisher \
         -k /var/pkg/ssl/Oracle_Solaris_11_Express_Support.key.pem \
         -c /var/pkg/ssl/Oracle_Solaris_11_Express_Support.certificate.pem \
         -O https://pkg.oracle.com/solaris/support/ solaris
pkg list -a ‘pkg://solaris/*’

Booting HP-UX Integrity server from ignite server on a different subnet without dhcp

Not sure if this is much of a secret, but it was elusive to the instructor of my HP-UX training class last spring.

On Integrity servers, you can boot via ignite to a server on a different subnet.
This also doesn’t need dhcp, which is handy.

The server is 10.10.10.22 and client is 10.10.20.20

from EFI Shell
Shell> dbprofile -dn ignite -sip 10.10.10.22 -cip 10.10.20.20 -gip 10.10.20.1 -m 255.255.255.0 -b “/opt/ignite/boot/nbp.efi”

Shell> lanboot select -dn ignite

HP-UX equivalent of LOFS

HP-UX doesn’t have a native tool for mounting image files like Solaris.

However, you can psuedo get the same functionality by creating a logicial volume, dd the image onto it and then mounting it

mkdir /isoimg
lvcreate -n ISOLV -L 3096 /dev/vg00
dd if=isoimage of=/dev/vg00/rISOLV bs=8192
mount -F cdfs -oro,rr /dev/vg00/ISOLV /isoimg

Just make sure that the logical volume is big enough to hold the entire image.

Printing out HBA and WWN information on HP-UX

Here is a quick way of printing out information on all the Fibre adapters in a HP-UX system

This one liner prints out the WWN of the HBA ports and the state

root@testserver # for i in `ioscan -fknC fc | grep ‘/dev/’`; do echo $i; fcmsutil $i;done | egrep ‘World|Hardware|/dev|Driver state’
/dev/fcd0
N_Port Node World Wide Name = 0x50014380033a1709
N_Port Port World Wide Name = 0x50014380033a1708
Switch Port World Wide Name = 0x2096000dec2e2ac0
Switch Node World Wide Name = 0x2016000dec22a641
Driver state = ONLINE
Hardware Path is = 0/3/1/0/4/0
/dev/fcd1
N_Port Node World Wide Name = 0x50014380033a170b
N_Port Port World Wide Name = 0x50014380033a170a
Switch Port World Wide Name = 0x0000000000000000
Switch Node World Wide Name = 0x0000000000000000
Driver state = AWAITING_LINK_UP
Hardware Path is = 0/3/1/0/4/1
/dev/fcd2
N_Port Node World Wide Name = 0x50014380033a1719
N_Port Port World Wide Name = 0x50014380033a1718
Switch Port World Wide Name = 0x2098000dec350940
Switch Node World Wide Name = 0x2015000dec217c81
Driver state = ONLINE
Hardware Path is = 0/7/1/0/4/0
/dev/fcd3
N_Port Node World Wide Name = 0x50014380033a171b
N_Port Port World Wide Name = 0x50014380033a171a
Switch Port World Wide Name = 0x0000000000000000
Switch Node World Wide Name = 0x0000000000000000
Driver state = AWAITING_LINK_UP
Hardware Path is = 0/7/1/0/4/1
Hardware Path is = 0/4/1/0

The following one liner will print out the same the WWN info of the HBA ports and adds any targets that it sees
Read more of this post

Displaying Progress of LVM sync / resync / resliver on HP-UX

When replacing disks (or sync’n mirrors for the first time) in LVM on HP-UX, there is no clear way of determining how far along in the process the system is.

In came up with a quick trick for calculating what percent of Logical extents are sync’d

Here is a nice one liner to display this. Just change the LV variable to point to the device file for the logical volume

LV=/dev/vg00/lvol5 ; echo `lvdisplay -v $LV | grep current | wc -l` `lvdisplay -v $LV | grep stale | wc -l` | awk ‘{printf ( “%3d percent Complete \n”, 100-$2/$1*100) }’

Alternatively, here is a for loop which will show the percent complete for any stale logical volume in the system.

for i in `vgdisplay -v 2>&1 | sed ‘/LV Name/N;s/\n/ /’ | grep “LV Name” | grep stale | awk ‘{print $3}’`;do
        printf “${i}:”; echo `lvdisplay -v $i | grep current | wc -l` `lvdisplay -v $i | grep stale | wc -l` | awk ‘{printf ( “%3d percent complete\n”, 100-$2/$1*100) }’
done

The output will look like:

/dev/vg00/lvol5: 70 percent complete

Quickly add Luns to a Solaris host

Here is a 1 liner for having Solaris rescan all of its fibre cards for new luns and then have them detected by Veritas.

This only works if you are using the built in Leadville drivers (which you probably should be running anyway).

If you are not familiar with vxdiskconfig, it simply runs devfsadm, followed by vxdctl enable

cfgadm | grep fc-fabric | awk ‘{print $1}’ | xargs -I {} cfgadm -c configure {};vxdiskconfig;vxdisk list

I you are not using Veritas on your system, you could alternatively do
cfgadm | grep fc-fabric | awk ‘{print $1}’ | xargs -I {} cfgadm -c configure {}; devfsadm -v

BTW, if you are still using the lpfc drivers, I would strongly recommend moving to the Leadville drivers as they work more consistently for dynamic LUN addition.
I had been very hesitant of using the Leadville drivers, remembering back to when I used to work at HDS and they internally referred to it as the LeadWeight driver.

However, after experiencing multiple production outages when the lpfc driver would not properly detecting SAN path failure (such as a port failure or a target disappearing and then reappearing). We made the change and I have been much happier and our systems have been very reliable when dealing with transient SAN events ever since. Our performance has also been extremely good.

Quickly setting up disks for Veritas

Here is a quick trick for quickly labeling and initializing a group of disks for Veritas

Say you want to initialize luns 10-20 and they are all on c2t50060E800547725Dd* and force a smi label.

printf “label 0 y n n” > /tmp/cmd
for ((i=10;i<21;i++)); do format -d $i -f /tmp/cmd -e ;done
vxdisk scandiskss
for ((i=0;i<12;i++)); do /etc/vx/bin/vxdisksetup -i c2t50060E800547725Dd$i;done

Depending on how many unlabeled LUNs you have, this can take a long time.