Tag Archive for 'hp-ux'

Mirror de un lvol en LVM de Linux

Para quien venga de HP-UX, resulta facil mirrorear un lvol bajo LVM: con un lvextend -m. En Linux, el lvextend -m simplemente no funciona…

De hecho el comando lvcreate si tiene una opcion -m, y esa si que funciona (lo he probado)! Pero con el lvextend no la coje.

Me he bajado las fuentes de lvm2. En commands.h he descubierto el comando lvconvert que no conocia:

alegrome# lvconvert
  Exactly one of --mirrors or --snapshot arguments required.
  lvconvert: Change logical volume layout

lvconvert [-m|--mirrors Mirrors [--corelog]]
        [--alloc AllocationPolicy]
        [-d|--debug]
        [-h|-?|--help]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [PhysicalVolume[Path]...]

lvconvert [-s|--snapshot]
        [-c|--chunksize]
        [-d|--debug]
        [-h|-?|--help]
        [-v|--verbose]
        [-Z|--zero {y|n}]
        [--version]
        OriginalLogicalVolume[Path] SnapshotLogicalVolume[Path]

Este comando si que parece funcionar. Probemos a mirrorear un lvol:

# lvconvert -m 1 /dev/vg02/lvweb
  Logical volume lvweb converted.

Miremos con un lvdisplay lo que nos ha hecho el comando:

alegrome# lvdisplay -m lvweb
  --- Logical volume ---
  LV Name                /dev/vg02/lvweb
  VG Name                vg02
  LV UUID                9I4wK7-2hn7-j4dI-o5yT-ngYx-8Wtd-m3no6q
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 MB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:6

  --- Segments ---
  Logical extent 0 to 49:
    Type                mirror
    Mirrors             2
    Mirror size         50
    Mirror log volume   lvweb_mlog
    Mirror region size  512.00 KB
    Mirror original:
      Logical volume    lvweb_mimage_0
      Logical extents   0 to 49
    Mirror destinations:
      Logical volume    lvweb_mimage_1
      Logical extents   0 to 49

A notar ahi: Type = mirror.

Como se puede ver, el lvweb ahora si esta en mirror. La verdad es que no he visto esto documentado en ningun sitio (¿alguien ha visto mas sobre esto?).

Para quitar el mirror (reducir), se haria asi:

# lvconvert -m 0 /dev/vg02/lvweb
  Logical volume lvweb converted.

# lvdisplay -m lvweb
  --- Logical volume ---
  LV Name                /dev/vg02/lvweb
  VG Name                vg02
  LV UUID                9I4wK7-2hn7-j4dI-o5yT-ngYx-8Wtd-m3no6q
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 MB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:6

  --- Segments ---
  Logical extent 0 to 49:
    Type                linear
    Physical volume     /dev/hdh4
    Physical extents    18370 to 18419

Con lvs vemos el estado del mirrorring

alegrome# lvs lvweb
  LV     VG   Attr   LSize Origin Snap%  Move Log         Copy%
  lvweb  vg02 mwi-ao 200M                    lvweb_mlog   12.22

En Attr, la “m” es de mirror.

Este post viene originado por un comentario de Rubik a un post de Ivan sobre “Crear un raid 1 a partir de un disco con datos sin formatear“.. Gracias a ambos.

Redistribuir los PV links de un VG (HP-UX) — Update

Respecto al post anterior sobre como redistribuir los PV links de un VG sobre los distinctos caminos a los discos, agradezco el comentario de RuBiCK apuntando a la opción -s del comando pvchange:

NAME
   pvchange - change characteristics and access path of a physical volume
   in an LVM volume group

SYNOPSIS
...
   /usr/sbin/pvchange [-A autobackup] -s pv_path
...
     -s  Immediately begin accessing the associated
         physical volume named by pv_path.
...

Usando este comando no es necesario quitar y reañadir los PV links al VG. Ademas de ser mas seguro, tambien se reduce considerablemente el script, quedando asi:

#!/usr/bin/ksh
# Distribuye los PV links sobre las controladoras
set -o nounset

VG=$1
I=0
for PV in $(
   vgdisplay -v $VG | grep "PV Name" |
   grep -v "Alternate Link" | awk '{ print $3 }' )
do

   LISTA_LINKS=$( pvdisplay $PV | grep "PV Name" | awk '{ print $3 }' | sort )
   NUM_LINKS=$( echo $LISTA_LINKS | wc -w )

   NEW=$(( I % NUM_LINKS + 1 ))
   PRI=$( echo $LISTA_LINKS | awk "{ print \$${NEW} }" )

   pvchange -A n -s $PRI
   (( I = I + 1 ))

done
vgcfgbackup $VG

Gracias RuBiCK por la contribución ;-).

Redistribuir los PV links de un VG (HP-UX)

Inspirado por el post de RuBiCK sobre como extender un VG con todos los PV links alternates de cada PV, se me occurrio hacer un script para distribuir todos los PV links sobre los distinctos caminos a los discos (es decir sobre las posibles controladoras). Esto no aplica si estamos usando un drivers que balancea el acceso a los discos y no hace uso de los pv links (por ejemplo Powerpath).

Por ejemplo, un VG de 3 PVs. Cada PV se ve por 4 caminos, por las controladoras c4, c6, c8 y c10.

Posiblemente, el primary path de los 3 PVs sea por la c4, mientras que los demas caminos estan en standby. Aun que no sea comparable a Powerpath, es mas interesante distribuir las I/O sobre todos los caminos posibles. Para esto, podemos redistribuir los primary path sobre los caminos posibles.

Por ejemplo: PV1 por la c4, PV2 por la c6 y PV3 por la c8 (y seguiriamos asi con los demas discos…)

Para hacerlo en caliente, lo que hace el script es quitar los caminos que no seran el primario y reañadirlos (en el orden correcto):

# pvdisplay /dev/dsk/c4t0d4
--- Physical volumes ---
PV Name                     /dev/dsk/c4t0d4
PV Name                     /dev/dsk/c6t0d4     Alternate Link
PV Name                     /dev/dsk/c8t0d4     Alternate Link
PV Name                     /dev/dsk/c10t0d4    Alternate Link

# vgreduce -A n $VG /dev/dsk/c8t0d4 /dev/dsk/c10t0d4 /dev/dsk/c4t0d4

# vgextend -A n $VG /dev/dsk/c8t0d4 /dev/dsk/c10t0d4 /dev/dsk/c4t0d4

# pvdisplay /dev/dsk/c6t0d4
--- Physical volumes ---
PV Name                     /dev/dsk/c6t0d4
PV Name                     /dev/dsk/c8t0d4     Alternate Link
PV Name                     /dev/dsk/c10t0d4    Alternate Link
PV Name                     /dev/dsk/c4t0d4     Alternate Link

He hecho el siguiente script para hacer el trabajo automaticamente con todos los discos de un VG:

#!/usr/bin/ksh
# Distribuye los PV links sobre las controladoras
set -o nounset

# bucle para cada primary link:
VG=$1
FILE=$( mktemp )
J=0
for PV in $(
   vgdisplay -v $VG | grep "PV Name" |
   grep -v "Alternate Link" | awk '{ print $3 }' )
do
   (( J = J + 1 ))
   I=1

   LISTA_LINKS=$( pvdisplay $PV | grep "PV Name" | awk '{ print $3 }' | sort )
   NUM_LINKS=$( echo $LISTA_LINKS | wc -w )

   for LINK in $( pvdisplay $PV | grep "PV Name" | awk '{ print $3 }' )
   do
      (( N = ( I + J ) % NUM_LINKS + 1 ))
      echo $PV $( echo $LINK | tr "t" "/" | cut -d/ -f 4 ) $LINK $I $N
      (( I = I + 1 ))
   done
done | sort -k 5 > $FILE

for PV in $(
   vgdisplay -v $VG | grep "PV Name" |
   grep -v "Alternate Link" | awk '{ print $3 }' )
do

   # Lista de links
   set -- $( grep $PV" " $FILE | awk '{ print $3 }' )

   PRIMARY=$1
   shift
   ALTERNATES=$*

   # esta bien el futur primary? (sino saltamos)
   pvdisplay $PRIMARY >/dev/null 2>&1 || continue

   vgreduce -A n $VG $ALTERNATES
   vgextend -A n $VG $ALTERNATES

done
vgcfgbackup $VG
rm $FILE

Cacti host templates for Unix v1.3

I’ve released a new version of my Cacti host templates for Unix systems (HP-UX, Solaris and Linux).

This new version introduces the following changes:
* ucd Load Average GT seemed somehow messed up in v1.2 (load5min missing in xml, reported by eyechart). I think it is solved now.
* New Uptime GT (all OS, contributed by Mikf here)

*WARNING*: Import each Host Template twice!!
It seems that sometimes the templates are not correctly imported after the first import (associated grath templates and/or data queries are missing). Importing the templates *once again* seems to solve the problem (at least in cacti 0.8.6g).

CactiFeel free to download version 1.3 of my Cacti host templates for Unix, and use and/or redistribute it under the terms of the GPL license.

You may also check this post on the Cacti forum, for further information and/or post comments here.

v1.2 of my Cacti host templates for Unix

Here is a new version of my Cacti host templates for Unix systems — read HP-UX, Solaris and Linux machines and maybe other Net-SNMP compatible OS.

This new version introduces the following changes:
* I’ve splitted the “Solaris Linux ucd/net-snmp” template into two separated flavours. That way I’ll be able to tweak the graph templates of each OS according to its own particularities;
* one example of this is the CPU graph template: while in the Linux template it show nice, sys and user %CPU, in the Solaris version it now shows: kernel, wait (instead of system) and user CPU. I’ve also removed nice CPU as it won’t graph on a Solaris box.
* I’ve removed the Detailled memory graph from the Solaris template, as Solaris doesn’t seem to report such detailled metrics . It’ll only be in the Linux flavour.

Feel free to download version 1.2 of the Unix Template Set for Cacti, and use and/or redistribute it under the terms of the GPL license.

You may also check this post on the Cacti forum, for further information.

Open question: Does any of the net-snmp templates I provide (Linux or Solaris flavour) produce good results for AIX hosts? Have somebody tried it?




Close
Powered by ShareThis