juin 29 2011

HPVM disk physical/virtual mapping script

Tag: Scripts,UnixUggla @ 17 h 02 min

This is a short script to create a physical (host)/virtual (guest) map.
This is a basic script written quickly, that was used to simplify data migration operations. So improvements welcomed.

    Requirements :

  • script must be run from host. (not guest)
  • ssh must be allowed using keys (no passwd) to all guests.
  • hpvmstatus command must be available from path.

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @hpvmstatus=`hpvmstatus`;
my @vms;
my $vm;

my %vm_data;

foreach(@hpvmstatus) {
        ($vm)=$_ =~ /^(.+)\s+[0-9]+\sHPUX\s+On/;
        if (defined($vm)){
                $vm =~ s/\s+//g;
                push (@vms,$vm);
        }
}

foreach $vm (@vms){
        my @hpvmstatus_vm=`hpvmstatus -P $vm`;

        foreach(@hpvmstatus_vm){
                #Device  Adaptor    Bus Dev Ftn Tgt Lun Storage   Device
                #======= ========== === === === === === ========= =========================
                #disk    avio_stor    0   2   0   0   0 disk      /dev/rdisk/disk17

                (my $ftn,my $tgt,my $lun,my $disk)=$_ =~ /^disk\s+avio_stor\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s+(\d+)\s+disk\s+(.+)$/;

                if (defined($ftn)){
                $vm_data{$vm}->{$disk}->{"dev"}=$ftn;
                $vm_data{$vm}->{$disk}->{"tgt"}=$tgt;
                $vm_data{$vm}->{$disk}->{"lun"}=$lun;

                #Convert tgt to the good legacy device
                my $tgtconv=sprintf("%02X",$tgt);
                my $tgtconv_part1;
                my $tgtconv_part2;

                ($tgtconv_part1)=$tgtconv=~/(.)./;
                ($tgtconv_part2)=$tgtconv=~/.(.)/;

                $tgtconv_part1=hex($tgtconv_part1);
                $tgtconv_part2=hex($tgtconv_part2);

                #$vm_data{$vm}->{$disk}->{"legacy"}="c".$ftn."t".$tgtconv_part2."d".$tgtconv_part1;
                $vm_data{$vm}->{$disk}->{"legacy"}="c\\dt".$tgtconv_part2."d".$tgtconv_part1; # Don't know how the instance number is defined (cX) so use a more gereric regexp
                }
        }
}

foreach $vm (@vms){
        my @ioscan=`ssh -q -o stricthostkeychecking=no -o batchmode=yes root\@$vm \"ioscan -m dsf\"`;

        foreach(keys(%{$vm_data{$vm}})){
                my $regex=$vm_data{$vm}->{$_}->{"legacy"}."\$";
                my @vdisk=grep(/$regex/,@ioscan);
                my $vdisk_str=join(",",@vdisk);
                ($vdisk_str)=split(",",$vdisk_str);
                $vdisk_str=~s#\s+/dev/rdsk/.+##g;
                $vdisk_str=~s/\s//g;
                $vm_data{$vm}->{$_}->{"vdisk"}=$vdisk_str;
        }
}

# Debuging purpose
#print Dumper(\%vm_data);

foreach $vm (@vms){
        printf("VM\tPhys\t\t\tVirt\n");

        foreach(keys(%{$vm_data{$vm}})){
                printf("%s\t%s\t%s\n",$vm,$_,$vm_data{$vm}->{$_}->{"vdisk"});

        }
}


mai 24 2011

Rescan tape drives

Tag: Scripts,UnixUggla @ 16 h 12 min

Last week we got an issue with VLS. We had to rescan hw to recover tape drives in CLAIMED status.
So I created this short script/command line to rescan HPUX 11.31.

for system in toto titi tata
do
echo "Processing $system"
ssh root@$system 'ioscan > /dev/null && for i in $(dmesg | grep "replace_wwid" | \
perl -ne '"'"'{(my $get) = $_ =~ m/instance = (.+)\) The/; print "$get\n"}'"'"'); \
do scsimgr -f replace_wwid -C tgtpath -I $i;done | sort -u && ioscan -fnkC tape'
done


mai 11 2011

How to crash your file #2

Tag: UnixUggla @ 14 h 47 min

Bad copy and paste.

oracle@lucifer >./sqlplus
...
...
oracle@lucifer >oracle@lucifer >./sqlplus

Ouch… ;)
Where can I get sqlplus from another server….

If you don’t understand, here is a clue…
Who is the bastard that set a « > » in prompt !


mai 11 2011

How to crash your file #1

Tag: UnixUggla @ 14 h 39 min

Pitfall due to completion and no brain…
Goal is to quickly encode from mp4 to avi….

# mplayer -o Big_bang_theory_S01E04.mp4 -ovc lavc -oac mp3lame Big_bang_theory_S01E04.mp4

Ouch… ;)
Download again….

If you don’t understand, here is a clue…
Do not forget file extension…


mai 11 2011

How to crash a prod DB #1

Tag: DB,UnixUggla @ 14 h 24 min

Short extract from .sh_history file….

cd $ORACLE_HOME
ls -la
cd bin
ls -la
ls -la | grep tns*
sqlplus
chmod u=rwx *

Ouch….. ;)
Dear customer, let me try to explain you….

If you don’t understand, here is a clue…

# ls -al oracle
-rwsr-s--x    1 oracle   dba       209822679 Oct 16 2009  oracle


avr 29 2011

Hit by multipath bug.

Tag: UnixUggla @ 11 h 58 min

Short article to keep a note about this bug.
We (colleague and I) added a lun to a RHEL 5.4 and configured it with multipath.
Everything was fine until we rebooted. We were stuck at early boot up stage with :

Cannot make directory [/var/lib] : Read-only file system

Looking for some ideas regarding this bug we finally found this RH identified bug : https://bugzilla.redhat.com/show_bug.cgi?id=409741
Issue is exactly the one describe in comment #11 by Blaz Podrzaj.

To fix it :

  1. we move /var/lib/multipath/bindings to /etc/multipath/bindings.
  2. edit /etc/multipath.conf and add the directive bindings_file           /etc/multipath/bindings in the defaults section.

This is a bit different from the solution provided by Blaz Podrzaj comments but we prefer not to have symlinks.
To my mind, having various solutions to fix an issue is something that makes linux really « fun ».


avr 19 2011

Rescan tape drive

Tag: UnixUggla @ 14 h 08 min

Quick article to keep track of the command.

Following this message in dmesg :

st0: Error 10000 (sugg. bt 0x0, driver bt 0x0, host bt 0x1).

Looks like the command below fix the issue.

echo "1" > /sys/class/scsi_tape/st0/device/rescan


mar 16 2011

HPVM B.04.20.05 update and vlan usage

Tag: UnixUggla @ 16 h 19 min

Article en anglais pour partager à l’international.

I recently got a severe issue upgrading HPVM to B.04.20.05.
Of course the « trap » was notified into the manual, but I worked to fix another issue, missed it and ran into serious problems.

So, the idea of this article is to avoid pitfalls documenting them.

  1. Avoid vlan unsupported configuration.

    Extracted from documentation (http://bizsupport2.austin.hp.com/bc/docs/support/SupportManual/c02023903/c02023903.pdf) :

    Do not use the hpvmnet command to create a virtual switch that
    is associated with a VLAN port on the VM Host (that is, a LAN created with lanadmin -V).
    This “nested VLAN” configuration is not supported.

    In the following configuration :

    root@hx05333: /root/home/root # lanscan
    Hardware Station        Crd Hdw   Net-Interface  NM  MAC       HP-DLPI DLPI
    Path     Address        In# State NamePPA        ID  Type      Support Mjr#
    0/0/0/3/0/0/2 0x64315000A911 4   UP    lan4 snap4     3   ETHER     Yes     119
    0/0/0/3/0/0/3 0x64315000A915 5   UP    lan5 snap5     4   ETHER     Yes     119
    0/0/0/3/0/0/4 0x64315000A912 6   UP    lan6 snap6     5   ETHER     Yes     119
    0/0/0/3/0/0/5 0x64315000A916 7   UP    lan7 snap7     6   ETHER     Yes     119
    0/0/0/3/0/0/6 0x64315000A913 8   UP    lan8 snap8     7   ETHER     Yes     119
    0/0/0/3/0/0/7 0x64315000A917 9   UP    lan9 snap9     8   ETHER     Yes     119
    0/0/0/4/0/0/0 0x64315000A918 2   UP    lan2 snap2     9   ETHER     Yes     119
    0/0/0/4/0/0/1 0x64315000A91C 3   UP    lan3 snap3     10  ETHER     Yes     119
    LinkAgg0 0x0017A477FE00 900 UP    lan900 snap900 12  ETHER     Yes     119
    VLAN5001 0x0017A477FE00 5001 UP    lan5001 snap5001 63  ETHER     Yes     119
    VLAN5000 0x0017A477FE00 5000 UP    lan5000 snap5000 62  ETHER     Yes     119
    LinkAgg1 0x000000000000 901 DOWN  lan901 snap901 13  ETHER     Yes     119
    LinkAgg2 0x000000000000 902 DOWN  lan902 snap902 14  ETHER     Yes     119
    LinkAgg3 0x000000000000 903 DOWN  lan903 snap903 15  ETHER     Yes     119
    LinkAgg4 0x000000000000 904 DOWN  lan904 snap904 16  ETHER     Yes     119
    

    1. lan900 is « bonding » of interface lan0 and lan1 carrying all the vlans.
    2. lan5000 is an interface that select a vlan(113) of lan900
    3. lan5001 is an interface that select a vlan(213) of lan900

    Clearly it means that lan5000 or lan5001 must not be connected to the virtual switch.
    Lan900 (the one with all the vlans) must be connected to the switch, and it is virtual switch job to manage the vlan tagging mechanism for all our VM.

    The configuration should be done in the following way.

    1. Create virtual switch.
      hpvmnet -c -S vmlan -n 900
      
    2. Define 2 ports with vlan 113 and 213
      hpvmnet -S vmlan -u portid:1:vlanid:113
      hpvmnet -S vmlan -u portid:2:vlanid:213
      
    3. Attach VM to the ports just created.
      hpvmmodify -P hx05374 -a network:avio_lan::vswitch:vmlan:portid:1
      hpvmmodify -P hx05374 -a network:avio_lan::vswitch:vmlan:portid:2
      
    4. Check virtual switch and VM are ok.
      root@hx05333: /root/home/root # hpvmnet
      Name     Number State   Mode      NamePPA  MAC Address    IPv4 Address
      ======== ====== ======= ========= ======== ============== ===============
      localnet      1 Up      Shared             N/A            N/A
      vmlan        10 Up      Shared    lan900   0x0017a477fe00
      

      root@hx05333: /root/home/root # hpvmnet -S vmlan
      Name     Number State   Mode      NamePPA  MAC Address    IPv4 Address
      ======== ====== ======= ========= ======== ============== ===============
      vmlan        10 Up      Shared    lan900   0x0017a477fe00
      
      [Port Configuration Details]
      Port    Port         Port     Untagged Number of    Active VM    Tagged
      Number  State        Adaptor  VLANID   Reserved VMs              VLANIDs
      ======= ============ ======== ======== ============ ============ =============
      1       Active       avio_lan 113      1            hx05374      none
      2       Active       avio_lan 213      1            hx05374      none
      

      root@hx05333: /root/home/root # hpvmstatus -p1
      [Virtual Machine Details]
      Virtual Machine Name VM #  OS Type State
      ==================== ===== ======= ========
      hx05374                  1 HPUX    On (OS)
      
      [Authorized Administrators]
      Oper Groups             :
      Admin Groups            :
      Oper Users              :
      Admin Users             :
      
      [Virtual CPU Details]
      #vCPUs Entitlement Maximum
      ====== =========== =======
           4       10.0%  100.0%
      
      [Memory Details]
      Total    Reserved
      Memory   Memory
      =======  ========
      17000 MB     64 MB
      
      [Dynamic Memory Information]
      Minimum     Target      Memory      Maximum
      Memory      Memory      Entitlement Memory
      =========== =========== =========== ===========
         512 MB    17018 MB          -     17000 MB
      
      [Storage Interface Details]
      Guest                                 Physical
      Device  Adaptor    Bus Dev Ftn Tgt Lun Storage   Device
      ======= ========== === === === === === ========= =========================
      disk    avio_stor    0   4   0   0   0 disk      /dev/rdisk/disk11
      disk    avio_stor    0   4   0   1   0 disk      /dev/rdisk/disk3
      disk    avio_stor    0   4   0   2   0 disk      /dev/rdisk/disk8
      disk    avio_stor    0   4   0   3   0 disk      /dev/rdisk/disk17
      
      [Network Interface Details]
      Interface Adaptor    Name/Num   PortNum Bus Dev Ftn Mac Address
      ========= ========== ========== ======= === === === =================
      vswitch   avio_lan   vmlan      1         0   0   0 36-af-e6-d1-20-bc
      vswitch   avio_lan   vmlan      2         0   1   0 8e-b5-a9-a9-14-23
      
      [Misc Interface Details]
      Guest                                 Physical
      Device  Adaptor    Bus Dev Ftn Tgt Lun Storage   Device
      ======= ========== === === === === === ========= =========================
      serial  com1                           tty       console
      
  2. Update HPVM to B.04.20.05.

    1. Patch the VM with QPK bundle.
    2. Add VM patches to avoid dynamic memory issue.

      This will avoid to be in the case defined by this article :
      http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c02692588&lang=en&cc=us&taskId=101&prodSeriesId=4146128&prodTypeId=18964

      Add the PHSS_41543 and PHSS_41550, this will give the following patch list due to dependencies.

      PHKL_41227 (2) clock cumulative patch
      PHSS_41191 (2) HPVM B.04.20.05 VMMIGRATE PATCH
      PHSS_41413 (2) HPVM B.04.20.05 vmGuestLib
      PHSS_41543 (2) [S] HPVM B.04.20.05 CORE PATCH
      PHSS_41550 (2) HPVM B.04.20.05 HPVM-VMSGTK
      
    3. Clean up VM.
      1. Remove HPVM product.
        swremove -x autoreboot=true T2767CC VMKernelSW
        

        Note : VMKernelSW should not be available on the VM

      2. Remove HostAVIO* product.
        swremove -p -x autoreboot=true  HostAVIOStor HostAvioLan
        swremove -x autoreboot=true  HostAVIOStor HostAvioLan
        
      3. Upgrade GuestAVIO* product.
        swinstall -p -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan
        swinstall -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan
        

      4. VM should now have only the following product.
        root@hx05374: /root/home/root # swlist -l bundle | egrep -i "HPVM|Integ"
          GuestAVIOStor         B.11.31.1009   HPVM Guest AVIO Storage Software
          GuestAvioLan          B.11.31.1009   HPVM Guest AVIO LAN Software
          HPVM-Guest            B.04.20     Integrity VM Guest
          LDAPUX                B.04.20        LDAP-UX Integration
          VMGuestLib            B.04.20     Integrity VM Guest Support Libraries
          VMProvider            B.04.20     WBEM Provider for Integrity VM
        
    4. Install full QPK on host including FEATURE11i bundle.
      Note : FEATURE11i will be checked by HPVM product script before upgrade.
    5. Upgrade AVIO software.
      swinstall -p -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan HostAVIOStor HostAvioLan
      swinstall -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan HostAVIOStor HostAvioLan
      
    6. Upgrade HPVM product.

      Do not force install, correct the dependencies issues by bringing the required bundle (VMGuestLib, VMGuestSW, AVIO* …) into the source depot.

      swinstall -p -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux T2767CC
      swinstall -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux T2767CC
      
    7. Check host, the following command should report something like this.
      root@hx05333: /root/home/root # swlist -l bundle | egrep "Integri|HPVM"
        GuestAVIOStor         B.11.31.1009   HPVM Guest AVIO Storage Software
        GuestAvioLan          B.11.31.1009   HPVM Guest AVIO LAN Software
        HostAVIOStor          B.11.31.1009   HPVM Host AVIO Storage Software
        HostAvioLan           B.11.31.1009   HPVM Host AVIO LAN Software
        T2767CC               B.04.20.05     Integrity VM
        VMGuestLib            B.04.20.05     Integrity VM Guest Support Libraries
        VMGuestSW             B.04.20.05     Integrity VM Guest Support Software
        VMKernelSW            B.04.20        Integrity VM Kernel Software
      

      Note : VMKernelSW remains at B.04.20, this is normal B.04.20.05 does not contain a new « host » kernel.

    8. Copy and register a depot from /opt/hpvm/guest-images/hpux/11iv3/hpvm_guest_depot.11iv3.sd on the host.
      swcopy -p -x enforce_dependencies=false -s /opt/hpvm/guest-images/hpux/11iv3/hpvm_guest_depot.11iv3.sd \* @ /var/depot/hpvm-guest
      swcopy -x enforce_dependencies=false -s /opt/hpvm/guest-images/hpux/11iv3/hpvm_guest_depot.11iv3.sd \* @ /var/depot/hpvm-guest
      swreg -l depot /var/depot/hpvm-guest
      
    9. Install VM tools on the VM.
      swinstall -p -x autoreboot=true -s hx05333:/var/depot/hpvm-guest HPVM-Guest vmProvider
      swinstall -x autoreboot=true -s hx05333:/var/depot/hpvm-guest HPVM-Guest vmProvider
      
    10. Check VM, the output should be similar to the following lines.
      root@hx05374: /root/home/root # swlist -l bundle | egrep -i "HPVM|Integri"
        GuestAVIOStor         B.11.31.1009   HPVM Guest AVIO Storage Software
        GuestAvioLan          B.11.31.1009   HPVM Guest AVIO LAN Software
        HPVM-Guest            B.04.20.05     Integrity VM Guest
        VMGuestLib            B.04.20.05     Integrity VM Guest Support Libraries
        VMProvider            B.04.20.05     WBEM Provider for Integrity VM
      

Now host and VM should be upgraded correctly.


mar 08 2011

Transformer HPUX en OS du 21eme siècle

Tag: UnixUggla @ 14 h 58 min

Un billet avec un peu d’humour, en référence à un collègue qui traite HPUX d’OS du 20eme siècle. (pas totalement faux non plus…)

La suite Internet express, permet d’ajouter plusieurs produits open source courant sur Linux. La liste est disponible sur le site.

https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXIEXP1131

Mon trio préféré :

  • lsof
  • rsync
  • sudo

Juste indispensable, mais pas disponible de facto sur HPUX. (oui ca fait peur….)
C’est mieux, mais bon il manque encore beaucoup d’outils pour se simplifier la vie (complétion de commande avancée, logrotate, fs partagé open source (pas cfs), gcc, mutt, etc…)


mar 02 2011

ssh trucs et astuces

Tag: UnixUggla @ 18 h 02 min

Quelques trucs et astuces avec ssh.

  • Ignorer la clef de host :
    ssh -o stricthostkeychecking=no server
    
  • Mode batch, aucun « prompt » (password, clef) n’est demandé, en gros ca marche ou pas :
    ssh -o batchmode=yes server
    
  • Mode quiet , aucun message d’alerte ou diagnostique est affiché :
    ssh -q server
    
  • Utiliser une commande avec des quotes (ex : awk). Il faut protéger les quotes avec des double quotes ("'") :
    ssh server 'vgdisplay | grep "VG Name" | awk '"'"'{print $NF}'"'"''
    

Page suivante »