Theres a few ways to tell if the solaris server you’re running on is a zone. My preferable method is to zoneadm list and see if it returns the global zone.
# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared
#!/bin/bash
zonecount () {
# Return 0 if we're a non-global zone.
# Otherwise return the count of number of
# installed non global zones +1
list=( `/usr/sbin/zoneadm list -pi` )
global=(`echo ${list[0]} | cut -d: -f2`)
if [ $global != "global" ]; then
# This is a non-global zone
return 0
else
# Number of items in array = number of zones
return ${#list[@]}
fi
}
zonecount
ZC=$?
if [ ${ZC} -eq 0 ]; then
echo "Non-global zone"
# Do some stuff you only want to do if its a non-global zone.
else
echo "Global zone with `(echo "${ZC} - 1" | bc)` running or installed non-global zones"
# Do some stuff you only want to do in the global zone.
fi
You must clean up the device tree after removing LUNs. The OS commands may vary for Solaris versions. This procedure uses Solaris 10.
Contact Sun Support if any of the steps in this section fail to produce the wanted results.
To clean up the device tree after you remove LUNs
The removed devices show up as drive not available in the output of the format command:
7. c4t600601604141200038FA4213BEF4E011d0
/scsi_vhci/ssd@g600601604141200038fa4213bef4e011
After the LUNs are unmapped using Array management or the command line, Solaris also displays the devices as either unusable or failing.
bash-3.00# cfgadm -al -o show_SCSI_LUN | grep -i unusable
c2::5006048acafe4a73,256 disk connected configured unusable
c3::5006048acafe4a7c,255 disk connected configured unusable
bash-3.00# cfgadm -al -o show_SCSI_LUN | grep -i failing
c2::5006048acafe4a73,71 disk connected configured failing
c3::5006048acafe4a7c,252 disk connected configured failing
If the removed LUNs show up as failing, you need to force a LIP on the HBA. This operation probes the targets again, so that the device shows up as unusable. Unless the device shows up as unusable, it cannot be removed from the device tree.
luxadm -e forcelip /devices/pci@1d,700000/SUNW,qlc@1,1/fp@0,0:devctl
To remove the device from the cfgadm database, run the following commands on the HBA:
cfgadm -c unconfigure -o unusable_SCSI_LUN c2::5006048acafe4a73
cfgadm -c unconfigure -o unusable_SCSI_LUN c3::5006048acafe4a7c
Repeat step 2 to verify that the LUNs have been removed.
Clean up the device tree. The following command removes the /dev/rdsk… links to /devices.
$devfsadm -Cv
p 0 alt wm 0 2c 1 alt wm 0 0c 3 alt wm 0 0c 4 alt wm 2 $ 5 alt wm 0 0c 6 alt wm 0 0c 7 alt wm 0 0c l q
tcpdump snoops a local interface, if you have enabled cdpinfo packets on your switches you can show the packets with the following. Replace eth0 with the interface you want to use of course.
tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'
I’ve heard about this solution, but never seen it for myself until today. When you have a failed disk, if all else fails, try giving it a good hard whack. Sometimes when a server has been up for many years, the disks aren’t enthusiastic about spinning up again and just want to rest. When you’ve got nothing more to lose, apply some physical encouragement.
As part of the Payment Card Industry Data Security Standards (PCI DSS) compliance, its not okay to leave credit card numbers lying around on your filesystems. If you are interested to tell if a long string of numbers is a credit card number, this subroutinne will run the number against the Luhn test, returning 1 if a match is positive.
sub luhn_test {
my $number = $_[0];
chomp $number;
# Split the number into single digits and store in array
@digits = split (//, $number);
my $total = 0; # Holds the running total
my $i = 1; # Digit counter
for $d (reverse (@digits)) { # Go through in reverse
if ( ! ($i++ % 2) ) { # If its a digit in an even
# position,
$d *= 2; # double it and
if ( $d > 9) { # if the result is over
# 9...
$d -= 9; # ...subtract 9
}
}
$total += $d; # Running total
}
if ( $total > 0 && !($total % 10) ) { # Mod 10 of this total
# Luhn algorithm passed if the total is greater than 10,
# and total mod 10 is zero (i.e. divisable by ten without
# a remainer)
return 1;
}
return 0;
}
Did you happen to forget which raw device contains which Oracle ASM disk… perhaps you’ve reinstalled Oracle, or had a recent recovery event and lost your configuration. There may be an easy way to do this with an oracle script, but I’m not really a DBA. The ASM disk name is contained in the disk label, from the 136th byte (0×88) and terminated by NULL.
/********************************************************************
*
* asm-diskname.c
*
*********************************************************************
* Revision 1.0 19/11/2011 solidola
* Initial revision
*
*/
#include <stdio.h>
#include <fcntl.h>
int main (int argc, char **argv) {
unsigned fp;
char buffer[512];
char diskname[20]="";
int a,i;
int offset = 0x88;
/* the asm disk name seems to start at 0x88 and is
terminated by NULL */
fp = open(argv[1], O_RDONLY);
if (fp == NULL ) {
printf("Unable to open %s", argv[1]);
return (1);
}
if (read(fp, buffer,512) 0 )
diskname[i]=buffer[offset + i++];
printf("%s\n",diskname);
return (0);
}