jeudi 18 octobre 2012

Be sure to be on different switchs !

It's good to have more than one fcs adapter... but it's better to be sure they are connected on different switchs !
Each id is different, if it is on another switch

in this case we have two  adapters (or 2 ports on the same card):

root:/# lsdev -c adapter | grep fcs
fcs0   Available 30-T1 Virtual Fibre Channel Client Adapter
fcs1   Available 31-T1 Virtual Fibre Channel Client Adapter


but on the same vio server ! ....

root:/# echo "vfcs" | kdb
           START              END
0000000000001000 0000000005770000 start+000FD8
F00000002FF47600 F00000002FFDF9C0 __ublock+000000
000000002FF22FF4 000000002FF22FF8 environ+000000
000000002FF22FF8 000000002FF22FFC errno+000000
F1000F0A00000000 F1000F0A10000000 pvproc+000000
F1000F0A10000000 F1000F0A18000000 pvthread+000000
read vscsi_scsi_ptrs OK, ptr = 0xF1000000C01A9380
(0)> vfcs
NAME      ADDRESS             STATE   HOST      HOST_ADAP  OPENED NUM_ACTIVE
fcs0      0xF10001019999A000  0x0008  vioprex1vfchost2  0x01    0x0000
fcs1      0xF10001019A3AC000  0x0008  vioprex1vfchost3  0x01    0x0000
and on the same swicth !!!


root:/# lsattr -El fscsi0
attach       switch    How this adapter is CONNECTED         False
dyntrk       yes       Dynamic Tracking of FC Devices        True
fc_err_recov fast_fail FC Fabric Event Error RECOVERY Policy True
scsi_id      0x340206  Adapter SCSI ID                       False
sw_fc_class  3         FC Class for Fabric                   True

root:/# lsattr -El fscsi1
attach       switch    How this adapter is CONNECTED         False
dyntrk       yes       Dynamic Tracking of FC Devices        True
fc_err_recov fast_fail FC Fabric Event Error RECOVERY Policy True
scsi_id      0x340501  Adapter SCSI ID                       False
sw_fc_class  3         FC Class for Fabric                   True



this other partition is ok :

# lsattr -El fscsi0
attach       switch    How this adapter is CONNECTED         False
dyntrk       yes       Dynamic Tracking of FC Devices        True
fc_err_recov fast_fail FC Fabric Event Error RECOVERY Policy True
scsi_id      0x1db40   Adapter SCSI ID                       False
sw_fc_class  3         FC Class for Fabric                   True

# lsattr -El fscsi1
attach       switch    How this adapter is CONNECTED         False
dyntrk       yes       Dynamic Tracking of FC Devices        True
fc_err_recov fast_fail FC Fabric Event Error RECOVERY Policy True
scsi_id      0x20db40  Adapter SCSI ID                       False
sw_fc_class  3         FC Class for Fabric                   True


Merci Patrice, pour l'info !

patch alt_disk install image


create disk copy :
     alt_disk_copy -O -B -d "hdisk25 hdisk26"
wake up disk copy :
     alt_rootvg_op -W -d hdisk25
update alternate disk copy : 
     alt_rootvg_op -C -b update_all -l /updates/5300-12-04
close alternate disk copy, and bosboot it:
     alt_rootvg_op -St

how to find the underlying vio server

I need to know, from a partition, how to find which vio server it relies on :

We need to use kdb  : 

on Npiv servers

root @test #  echo "vfcs" | kdb
           START              END
0000000000001000 0000000004090000 start+000FD8
F00000002FF47600 F00000002FFDF9C0 __ublock+000000
000000002FF22FF4 000000002FF22FF8 environ+000000
000000002FF22FF8 000000002FF22FFC errno+000000
F1000F0A00000000 F1000F0A10000000 pvproc+000000
F1000F0A10000000 F1000F0A18000000 pvthread+000000
read vscsi_scsi_ptrs OK, ptr = 0x0
(0)> vfcs
NAME      ADDRESS             STATE   HOST      HOST_ADAP  OPENED NUM_ACTIVE
fcs0      0xF1000A0000156000  0x0008  vioserver1vfchost0  0x01    0x0000

root @test # 

on vscsi servers

root @test #  echo "cvai" | kdb | grep vscsi
Preserving 30612 bytes of symbol table [./usr/lib/drivers/vscsi_initdd]
read vscsi_scsi_ptrs OK, ptr = 0xF1000000A0138378
vscsi0     0x000007 0x0000000000 0x0                vio73->vhost7
vscsi1     0x000007 0x0000000000 0x0                vio74->vhost7

Some stuff....

SED : (merci nico)

to remove, with a sed command, every thing before the dot :

echo " aaa.bbb" | sed 's/^.*\.//g'
bbb

^ = from the line beginning
. = one caracter

.* (dot with *) every caracters


Python : 

I have the following file, which contains server names, and dates.

root@test # cat file
server_a
09192012
09292012
09302012
server_b

 04022012
04082012
04262012
10072012
...


The date is american format, so i need to convert it in europeen format, so
reverse chain 2 by 2  (convert date from mmddyyyy to ddmmyyyy)

the simplest python command to do that is :

>>> x=06242012 
>>>x=x[2:4:]+x[0:2:]+x[4:8::]
>>> x
'24062012'


As i need to use it on the command line, to process a verrryy large file, i built a simple python file :

root@test #cat conv.py

#!/bin/python
# -*-coding:utf-8 -*

import sys
for line in sys.stdin:
        line=line.strip("\r\n") # need to remove trailing \n because my var is not numbers if there is a \n
        if line.isdigit():          # we only rework lines that are numbers
                line=line[2:4:]+line[0:2:]+line[4:8:]
        print line


root@test #cat file | ./conv.py 

server_a
19092012
29092012
30092012
server_b
22022012
18042012
26042012
07102012
...

 job's done...

same stuff with perl (one liner!) (merci Guigui)

root@test #echo 09192012 | perl -ne "s/(\d\d)(\d\d)(\d\d\d\d)/\2\/\1\/\3/;print"
19/09/2012