Monthly Archive for February, 2008

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.

sleep en la shell de Windows (cmd.exe)

Estaba buscando como hacer un sleep de 1 minutos en un .bat de Windows (CMD.EXE). Encontre esta forma, es original :-) :

@  ping -n 60 127.0.0.1 > NUL 2>&1

RHEL5, yum + proxy = Error

En un RedHat EL 5, al hacer un yum con proxy recibo el siguente mensaje: “Error: Cannot open/read repomd.xml file for repository: rhel-i386-server-5″

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)

# export http_proxy="http://localhost:8888"
# yum update
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Setting up Update Process
Setting up repositories
Error: Cannot open/read repomd.xml file for repository: rhel-i386-server-5

En el proxy recibimos lo siguiente:

[Fiddler] Request Header parsing failed. Request was:
43 4F 4E 4E 45 43 54 20 78 6D 6C 72 70 63 2E 72 68 6E 2E 72 65 64 68 61  CONNECT xmlrpc.rhn.redha
74 2E 63 6F 6D 3A 34 34 33 20 48 54 54 50 2F 31 2E 31 0D 0A 0D 0A        t.com:443 HTTP/1.1....

Encontre la solucion googleando un poco (solo una pagina hablaba de ello), pero probe la solucion y funciono:

It’s a bug in the crypto lib of python. It doesn’t add the HOST in the
headers of the HTTP/1.1.

Hay que editar el fichero /usr/lib/python2.4/site-packages/M2Crypto/httpslib.py en la maquina y añadir la linea siguiente entre las lineas 165 y 166:

msg = msg + "Host: %s:%d\\r\\n" % (self._real_host, self._real_port)

Quedando asi:

    def _get_connect_msg(self):
        """ Return an HTTP CONNECT request to send to the proxy. """
        msg = "CONNECT %s:%d HTTP/1.1\\r\\n" % (self._real_host, self._real_port)
        msg = msg + "Host: %s:%d\\r\\n" % (self._real_host, self._real_port)
        if self._proxy_auth:
            msg = msg + "%s: %s\\r\\n" % (self._AUTH_HEADER, self._proxy_auth)
        msg = msg + "\\r\\n"
        return msg

Una vez hecho esto, ya funciona bien:

# yum check-update
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
Setting up repositories
rpmforge                  100% |=========================| 1.1 kB    00:00
rhel-i386-server-5        100% |=========================| 1.4 kB    00:00
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 1.5 MB    00:00
################################################## 6175/6175
primary.xml.gz            100% |=========================| 1.1 MB    00:05
################################################## 3219/3219



Close
Powered by ShareThis