martes, 24 de noviembre de 2009

Como configurar raid 1 con Lvm en ambientes productivos 2

remplazamos  en el archivo /etc/mtab  la siguiente linea  /dev/sda1 con  /dev/md0

# vi /etc/mtab

   /dev/mapper/VolGroup00-LogVol00 / ext3 rw 0 0
   none /proc proc rw 0 0
   none /sys sysfs rw 0 0
   none /dev/pts devpts rw,gid=5,mode=620 0 0
   usbfs /proc/bus/usb usbfs rw 0 0
   /dev/md0 /boot ext3 rw 0 0
   none /dev/shm tmpfs rw 0 0
   none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
   sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0

editamos el archivo de bootloader   /boot/grub/menu.lst debajo de la linea default=0 agregamos fallback=1 
esto hará que cuando el sistema arranque y tenga un fallo en el default , tome el siguiente kernel para arrancar correctamente .


# vi /boot/grub/menu.lst


    default=0
    fallback=1
    timeout=5

el archivo debe parecerse a lo siguiente


default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu

title CentOS (2.6.9-89.0.15.ELsmp)
        root (hd1,0)
        kernel /vmlinuz-2.6.9-89.0.15.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.9-89.0.15.ELsmp.img
title CentOS (2.6.9-89.0.15.ELsmp)
        root (hd0,0)
        kernel /vmlinuz-2.6.9-89.0.15.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.9-89.0.15.ELsmp.img
title CentOS (2.6.9-89.0.11.ELsmp)
        root (hd0,0)
        kernel /vmlinuz-2.6.9-89.0.11.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.9-89.0.11.ELsmp.img

respaldamos y hacemos la imagen de arranque  para nuestro disco nuevo "uname" nos entregara la versión de kernel que estamos ejecutando .

# mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig
# mkinitrd /boot/initrd-`uname -r`.img `uname -r`


Si el sistema falla debemos tener un disco de seguridad . y regresar las configuraciones iniciales .

movemos nuestros datos del  disco duro sin RAID a nuestro Arreglo de RAID.
Primero movemos la particion LVM del /dev/sda2  al  /dev/md1

# pvmove /dev/sda2 /dev/md1

esto tomara un rato  dependiendo de la cantidad de información contenida . Al terminar  removemos el grupoVolGroup00   y le indicamos al sistema que no use mas  LVM  /dev/sda2

# vgreduce VolGroup00 /dev/sda2
# pvremove /dev/sda2

cambiamos la particion a tipo raid  como en el disco anterior

# fdisk /dev/sda

==============================

The number of cylinders for this disk is set to 2797.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
=====================================


al terminar agregamos la particion creada a la RAID

#mdadm --add /dev/md1 /dev/sda2

Podemos observar el progreso de sincronizacion de los arreglos  con un cat

#watch  cat /proc/mdstats

montamos la particion /dev/md0

#mkdir /mnt/md0 ; mount /mnt/md0 /dev/md0

copiamos el contenido de /dev/sda1 a /dev/md0

# cd /boot
# cp -dpRx  . /dev/md0

Instalamos el Grub en el disco duro
# grub
grub>  root (hd0,0)
grub>  (hd0,0)

grub>  root (hd1,0)
grub>  (hd1,0)
grub> quit

# reboot

Convertimos el /dev/sda1 a linux raid

#fdisk /dev/sda

convertimos de la misma manera que las anteriores. Agregamos la nueva particion a la RAID

# mdadm --add /dev/md0 /dev/sda1
#watch cat /proc/mdstat

creamos y verificamos como quedo la lista de RAID

# mdadm --examine --scan > /etc/mdadm.conf
# cat /etc/mdadm.conf

reiniciamos el sistema
# reoboot





No hay comentarios:

Publicar un comentario