Instalar y configurar RAID por software en una maquina virtual ubuntu12.04 server
Instalar y configurar RAID por software en una maquina virtual ubuntu 12.04 server
Para una pequeña introducción decir que RAID es una forma de distribuir datos en varios discos y que puede ser gestionada por hardware dedicado o por software. Además, existen sistemas RAID híbridos basados en software y hardware y además existen varios tipos de RAID.
En este caso creare un sistema por software, para lo cual nos valdremos de una maquina virtual con ubuntu 12,04 server, donde el sistema elegido será RAID 1 (espejo), ya que si bien no es el sistema RAID más rápido, si nos ofrece una gran seguridad al replicar los datos, en este caso en dos discos duros.
- Primero añadiremos dos discos duros:
- Ahora un poco de consola(maquina virtual):
root@ubuntu:/#sudo su
root@ubuntu:/#apt-get install mdadm
- Para ver que códigos tienen los discos duros que hemos creado:
root@ubuntu:/# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d3320
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 39845887 19921920 83 Linux
/dev/sda2 39847934 41940991 1046529 5 Extended
/dev/sda5 39847936 41940991 1046528 82 Linux swap / Solaris
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
- Ahora que ya sabemos los dispositivos a utilizar, creamos el sistema RAID 1, en el dispositivo /dev/md0, indicando el numero de dispositivos a utilizar, en este caso 2, así como la ubicación de los 2 dispositivos a utilizar:
root@ubuntu:/# mdadm -C /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb /dev/sdc
mdadm: /dev/sdb appears to contain an ext2fs file system
size=41943040K mtime=Tue Oct 2 12:39:27 2012
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: /dev/sdc appears to contain an ext2fs file system
size=41943040K mtime=Tue Oct 2 12:39:15 2012
Continue creating array? (y/n) y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
- Una vez creado el dispositivo RAID, procedemos a formatearlo:
root@ubuntu:/# mkfs /dev/md0
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10477536 blocks
523876 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
- Creamos el directorio que utilizara el sistema RAID y se monta en el dispositivo que se creo para el sistema RAID:
root@ubuntu:/# mkdir /datos
root@ubuntu:/# mount /dev/md0 /datos
- Para obtener información acerca del RAID:
root@ubuntu:/# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Wed Oct 3 01:05:17 2012
Raid Level : raid1
Array Size : 41910144 (39.97 GiB 42.92 GB)
Used Dev Size : 41910144 (39.97 GiB 42.92 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Wed Oct 3 01:28:37 2012
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : ubuntu:0 (local to host ubuntu)
UUID : 2fc9f6d0:e7667f17:83b1b273:b34614f6
Events : 19
Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc
- Configuraremos el sistema RAID para que se monte al inicio:
nano /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=7848f226-f5f1-4cee-ba55-37bb978930e1 / ext4 errors=remoun$
# swap was on /dev/sda5 during installation
UUID=1df5c0e7-32ce-4fd9-ba3a-9420acf1b2e3 none swap sw $
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
/dev/md0 /datos ext2 defaults 0 0
reboot
*En este momento no dará un error de que no ha encontrado el dispositivo datos, o algo así, pasad de él y presionamos "s".
- Volvemos a entrar en la consola y listamos los dispositivos md que existen:
root@ubuntu:/#sudo su
root@ubuntu:/# ls /dev/md*
/dev/md127
/dev/md:
ubuntu:0
- Con esta información volvemos a editar el fichero /etc/fstab y modificamos la línea que nos montaba el sistema RAID:
root@ubuntu:/# nano /etc/fstab
GNU nano 2.2.6 File: /etc/fstab Modified
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda1 during installation
UUID=7848f226-f5f1-4cee-ba55-37bb978930e1 / ext4 errors=remoun$
# swap was on /dev/sda5 during installation
UUID=1df5c0e7-32ce-4fd9-ba3a-9420acf1b2e3 none swap sw $
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
/dev/md127 /datos ext2 defaults 0 0
- Volvemos a montar el fichero fstab sin necesidad de reiniciar:
root@ubuntu:/#mount -a
- Comprobamos que efectivamente a montado el RAID en el directorio /datos:
- Y que son los discos duros creados para la ocasión los utilizados en el sistema RAID:
No hay comentarios:
Publicar un comentario