一 什么是RAID1
RAID1,可称为镜像,将数据写到多个磁盘,比如一组数据叫做 A,那么数据会这样存在:A、A ,这样数据安全性高,但性能不佳。
两组以上的N个磁盘相互作镜像,在一些多线程操作系统中能有很好的读取速度,另外写入速度有微小的降低。除非拥有相同资料的主磁碟与镜像同时损坏,否则只要一个磁盘正常即可维持运作,可靠性最高。RAID 1就是镜像。其原理为在主硬盘上存放数据的同时也在镜像硬盘上写一样的数据。当主硬盘(物理)损坏时,镜像硬盘则代替主硬盘的工作。因为有镜像硬盘做数据备份,所以RAID 1的数据安全性在所有的RAID级别上来说是最好的。但无论用多少磁碟做RAID 1,仅算一个磁碟的容量,是所有RAID上磁盘利用率最低的一个级别。
二 RAID1演示
第一步 对磁盘进行分区
#对/dev/sdb进行分区
root@serv01 ~]# fdisk /dev/sdb
#对/dev/sdc进行分区
root@serv01 ~]# fdisk /dev/sdc
[root@serv01 ~]# ls /dev/sdb
sdb sdb1
[root@serv01 ~]# ls /dev/sdc
sdc sdc1
第二步 制作RAID1
[root@serv01 ~]# mdadm -C /dev/md1 -l 1 -n2 /dev/sdb1 /dev/sdc1
mdadm: /dev/sdb1 appears to contain anext2fs file system
size=208812K mtime=Wed Jul 3122:17:43 2013
mdadm: /dev/sdb1 appears to be part of araid array:
level=raid0 devices=0 ctime=Thu Jan 1 07:00:00 1970
mdadm: partition table exists on /dev/sdb1but will be lost or
meaningless after creating array
mdadm: Note: this array has metadata at thestart 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
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
#格式化
[root@serv01 ~]# mkfs.ext4 /dev/md1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 523853 blocks
26192 blocks (5.00%) reserved for the superuser
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments pergroup
8192 inodes per group
Superblock backups stored on blocks:
32768,98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystemaccounting information: done
This filesystem will be automaticallychecked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
第三步 挂载
[root@serv01 ~]# mount /dev/md1 /web
[root@serv01 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Jul 2300:54:37 2013
#
# Accessible filesystems, by reference, aremaintained under '/dev/disk'
# See man pages fstab(5), findfs(8),mount(8) and/or blkid(8) for more info
#
UUID=110fab7c-85c4-4bae-9114-98bc2ada24d8/ ext4 defaults 1 1
UUID=ab434325-bf02-48e9-8ce7-78494a8ac71e/boot ext4 defaults 1 2
UUID=02ed2b3b-b7e1-493d-9a43-8e1dcac8aa6f/opt ext4 defaults 1 2
UUID=a088a35a-16d8-456a-a177-95c769c16e41swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs