martes, 24 de noviembre de 2009

Como configurar raid 1 con Lvm en ambientes productivos

Este manual que me ha servido mucho es de Falko Timme,

En el explica como configurar RAID en sistemas productivos con LVM y GRUB. En este manual se utilizara Centos 5 , 2 discos duros /dev/sda y /dev/sdb los cuales deben de ser de las mismas características /dev/sda/ ya esta configurado y /dev/sdb es un disco nuevo sin informacion.



  • /dev/sda1: /boot partition, ext3;
  • /dev/sda2: es usada para LVM (volume group VolGroup00) y contine / (volume LogVol00) y swap (volume LogVol01).
Al fina obtendremos el siguiente resultado:

  • /dev/md0 (puesto por /dev/sda1 y /dev/sdb1): /boot partition, ext3;
  • /dev/md1 (puesto por /dev/sda2 y /dev/sdb2): LVM (volume group VolGroup00), contiene / (volume LogVol00) y swap (volume LogVol01).
La situación actual es la siguiente :

comando df muestra la cantidad de espacio disponible y usado en las particiones

# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
266G 139G 115G 55% /
/dev/sda1 99M 75M 19M 80% /boot
none 3.9G 0 3.9G 0% /dev/shm


fdisk es un comando de manipulación de particiones

# fdisk -l

Disk /dev/sda: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 35539 285362595 8e Linux LVM

Disk /dev/sdb: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdb doesn't contain a valid partition table


utilizamos el comando pvdisplay que permite ver los atributos de uno o mas dispocitivos fisicos de almacenamiento

# pvdisplay

--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 272.14 GB / not usable 18.41 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 8708
Free PE 5
Allocated PE 8703
PV UUID UOsZLo-tA91-Gg6H-AR4H-zNC5-aFre-6Oi7b5


utilizamos vgdisplay para ver los atributos de los grupos de volúmenes

# vgdisplay

--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 272.12 GB
PE Size 32.00 MB
Total PE 8708
Alloc PE / Size 8703 / 271.97 GB
Free PE / Size 5 / 160.00 MB
VG UUID CyPUXB-5FI0-FT5m-3abs-4btK-2wLf-LqGSl2


utiliamos el comando lvdiplay para ver los atributos de los volúmenes lógicos

# lvdisplay

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID v50HGy-DfSm-Qn2c-aEms-faqa-fl4V-jnUNfP
LV Write Access read/write
LV Status available
# open 1
LV Size 270.03 GB
Current LE 8641
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID kjJlJm-yGgQ-Ummv-NNeM-1jAC-Zqda-ec7FWN
LV Write Access read/write
LV Status available
# open 1
LV Size 1.94 GB
Current LE 62
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

estos datos nos serviran para compara informacion al terminar de hacer nuestra configuración. Instalamos la paqueteria necesaria

# yum-y install mkinitrd mdadm

instalamos los módulos necesarios al kernel



# modprobe linear
# modprobe multipath
# modprobe raid0
# modprobe raid1
# modprobe raid5
# modprobe raid6
# modprobe raid10


Verificamos la correcta integración de los módulos cargados

# cat /proc/mstats

el resultado es el siguiente


Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
unused devices:


copiamos la particiones del /dev/sda al /dev/sdb para que los discos tengan exactamente la misma estructura

# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdb: 35539 cylinders ,255 heads, 63 sectors/track,
Units = cylinders of 16065 * 512 = 8225280 bytes


sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sdb1 * 63 208844 208782 83 Linux
/dev/sdb2 208845 20964824 20755980 8e Linux LVM
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

utilizamos el comando fdisk para verificar que tengan la misma estructura.

# fdisk -l

Disk /dev/sda: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 35539 285362595 8e Linux LVM

Disk /dev/sdb: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 83 Linux
/dev/sdb2 14 35539 285362595 8e Linux LVM


ahora cambiaremos el tipo de partición para el disco /dev/sdb para que funcione como raid0

# fdisk /dev/sdb


The number of cylinders for this disk is set to 1305.
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):
<-- m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help):
<-- t
Partition number (1-4): <-- 1
Hex code (type L to list codes): <-- L

0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris
1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 82 Linux swap / So c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT-
4 FAT16 <32m style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "> 5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data
6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df BootIt
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
14 Hidden FAT16 <3 style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot fb VMware VMFS
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
Hex code (type L to list codes):
<-- fd
Changed system type of partition 1 to fd (Linux raid autodetect)

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.
Syncing disks.


verificamos que las particiones se convirtieron correctamente .

# fdisk -l

Disk /dev/sda: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 35539 285362595 8e Linux LVM

Disk /dev/sdb: 292.3 GB, 292326211584 bytes
255 heads, 63 sectors/track, 35539 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 13 104391 fd Linux raid autodetect
/dev/sdb2 14 35539 285362595 fd Linux raid autodetect


Nos aseguramos que no exista ningún remanente de particiones RAID anteriores

# mdadm --zero-superblock /dev/sdb1
# mdadm --zero-superblock /dev/sdb2


Creamos las particiones RAID en los discos /dev/sdb1 y /dev/sdb2 por el momento no podemos crear las de /dev/sda1 y /dev/sda2 por que el sistema esta funcionando con esas particiones .



# mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1
# mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2

verificamos con el comando cat que los RAID se activaron correctamente

# cat /proc/mdstat

ahora creamos el sistema de archivos que vamos a utilizar en nuestra No LVM_RAID

#mkfs.ext3 /dev/md0

ahora cremaos el sistema de volumens para nuestra particion RAID

# pvcreate /dev/md1

creamos el grupo de volúmenes extendido

# vgestend VolGrup00 /dev/md1

ahora creamos el archivo de configuracion /etc/mdadm.conf

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

*** debemos tener a la mano un disco de emergencia y resplado de los archivos que estamos modificando.

Modificamos el archivo /etc/fstab y cambialos la etiqueta LABEL=/boot /boot por /dev/md0 /boot

# vi /etc/fstab

continua

No hay comentarios:

Publicar un comentario