全部博文(1144)
分类: LINUX
2006-03-06 20:40:45
RAID 0
This level of RAID makes it faster to read and write to the hard drives. However, RAID 0 provides no data redundancy. It requires at least two hard disks.
Reads and writes to the hard disks are done in parallel, in other words, to two or more hard disks simultaneously. All hard drives in a RAID 0 array are filled equally. But since RAID 0 does not provide data redundancy, a failure of any one of the drives will result in total data loss. RAID 0 is also known as 'striping without parity.'
特征:并行读写数据,性能高,但没有数据冗余,阵列中任何一个硬盘坏掉,意味着所有数据丢失
容量:所有硬盘容量之和
条件:至少两块硬盘,做为RAID的分区大小必须是几乎相同的.
首先将各个分区的分区类型标识为FD:
[root@LFS ~]#fdisk /dev/hda
Command (m for help):t
Partition number (1-4):1
Hex code (type L to list codes):fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help):p
/dev/hda1 1 646 325552+ fd Linux raid autodetect
使用raidtools-1.00.3创建raid-0:
编写raid的配置文件/etc/raidtab:
在/usr/share/doc/raidtools-1.00.3下有样例文件
raiddev /dev/md0
raid-level 0
nr-raid-disks 2
nr-spare-disks 0
persistent-superblock 1
chunk-size 4
device /dev/hda1
raid-disk 0
device /dev/hdb1
raid-disk 1
mkraid依据raidtab创建raid:
[root@LFS ~]#mkraid /dev/md0
......
raid0: done.
raid0 : md_size is 650880 blocks
raid0 : conf ->hash_spacing is 650880 blocks
raid0 : nb_zone is 1.
raid0 : Allocating 4 byte for hash
使用mdadm创建raid-0:
[root@LFS ~]#mdadm --create --verbose /dev/md0 --level=raid0 \
--raid-devices=2 --chunk=4 /dev/hda1 /dev/hdb1
......
raid0: done.
raid0 : md_size is 650880 blocks
raid0 : conf ->hash_spacing is 650880 blocks
raid0 : nb_zone is 1.
raid0 : Allocating 4 byte for hash
mdadm: array /dev/md0 started .
[root@LFS ~]#
查看状态:
[root@LFS ~]#cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 hdb1[1] hda1[0]
650880 blocks 4k rounding
unused devices:
[root@LFS ~]#
创建文件系统,挂载:
[root@LFS ~]#mkreiserfs /dev/md0
[root@LFS ~]#mount -t reiserfs /dev/md0 /mnt/raid0
加入到/etc/fstab,系统启动自动挂载:
/dev/md0 /mnt/raid0 reiserfs defaults 1 2
Commands in raidtab
Command
Description
nr-raid-disks
Number of RAID disks to use
nr-spare-disks
Number of spare disks to use
persistent-superblock
Required for autodetection
chunk-size
Amount of data to read/write
parity-algorithm
How RAID 5 should use parity
RAID 1
This level of RAID mirrors information to two or more other disks. In other words, the same set of information is written to two different hard disks. If one disk is damaged or removed, you still have all of the data on the other hard disk. The disadvantage of RAID 1 is that data has to be written twice, which can reduce performance. You can come close to maintaining the same level of performance if you also use separate hard disk controllers. That prevents the hard disk controller from becoming a bottleneck.
<>And it is expensive. To support RAID 1, you need an additional hard disk for every hard disk worth of data. RAID 1 is also known as disk mirroring.
特征:数据冗余,可靠性强。任何一块硬盘坏掉,不会丢失数据。写入慢,读取快。
容量:所有硬盘容量/2
条件:至少两块硬盘,做为RAID的分区大小必须是几乎相同的.
raidtools-1.00.3:
编写/etc/raidtab :
raiddev /dev/md1
raid-level 1
nr-raid-disks 2
nr-spare-disks 1
persistent-superblock 1
chunk-size 4
device /dev/hda2
raid-disk 0
device /dev/hdb2
raid-disk 1
device /dev/hdc2
spare-disk 0
[root@LFS ~]#mkraid /dev/md1
使用mdadm创建raid-1:
[root@LFS ~]#mdadm --create --verbose /dev/md1 --level=raid1 \
--raid-devices=2 --spare-devices=1 --chunk=4 /dev/hda2 /dev/hdb2 /dev/hdc2
[root@LFS ~]#cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdc2[2] hdb2[1] hda2[0]
325440 blocks [2/2] [UU]
unused devices:
[root@LFS ~]#mkreiserfs /dev/md1
[root@LFS ~]#mount -t reiserfs /dev/md1 /mnt/raid1
device /dev/hdc2
spare-disk 0
表示用/dev/hdc2做为spare disk,当hda2或hdb2坏掉时,raid会自动启用/dev/hdc2做为镜像.