根据raid0属性,构建时至少需要两块硬盘,硬盘类型不限
假设系统后加入3块scsi硬盘,系统识别后分别是sdb、sdc、sdd
各分成一个区,这里先设置sdb
[root@myserver root]# fdisk /dev/sdb
The number of cylinders for this disk is set to 1044.
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):n –新建分区
First cylinder (1-1044, default 1):1 –直接回车就是默认
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):1044 –直接回车就是默认
Using default value 1044
Command (m for help): w –保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
The new table will be used at the next reboot.
Syncing disks.
[root@myserver root]# fdisk -l /dev/sdb –查看分区结果,这块硬盘只分一个区,所以只有一个”sdb1″
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1044 3068383+ 83 Linux
同样方法对另外两个新加硬盘进行分区,得到 /dev/sdc1 和 /dev/sdd1
下面看系统中是否已经安装了raid软件包
[root@myserver root]# rpm -q raidtools
raidtools-1.00.3-2 –已经安装
[root@myserver root]# rpm -ql raidtools-1.00.3-2 –查看示范配置文件路径
/usr/share/doc/raidtools-1.00.3/raid0.conf.sample
/usr/share/doc/raidtools-1.00.3/raid1.conf.sample
/usr/share/doc/raidtools-1.00.3/raid4.conf.sample
/usr/share/doc/raidtools-1.00.3/raid5.conf.sample
/usr/share/doc/raidtools-1.00.3/raidtab.sample
–
–
–
[root@myserver root]# cp /usr/share/doc/raidtools-1.00.3/raid0.conf.sample /etc/raidtab
–把raid0的示范配置文件拷到/etc下,并命名为raidtab
修改raidtab文件内容以符合当前情况
# Sample raid-0 configuration
raiddev /dev/md0 –raid设备
raid-level 0 # it’s not obvious but this *must* be –raid级别
# right after raiddev
persistent-superblock 0 # set this to 1 if you want autostart,
# BUT SETTING TO 1 WILL DESTROY PREVIOUS
# CONTENTS if this is a RAID0 array created
# by older raidtools (0.40-0.51) or mdtools!
chunk-size 16
nr-raid-disks 3 –由几块硬盘组成
nr-spare-disks 0
device /dev/sdb1 –第一块
raid-disk 0 –硬盘序号0,代表第一块
device /dev/sdc1 –第二块
raid-disk 1 –硬盘序号1,代表第二块
device /dev/sdd1 –第三块
raid-disk 2 –硬盘序号2,代表第三块
[root@myserver root]# mkraid /dev/md0 –创建raid设备
handling MD device /dev/md0
analyzing super-block
[root@myserver root]# mkfs.ext3 /dev/md0 –格式化已创建的raid设备
[root@myserver root]# mount /dev/md0 /mnt/md0 –挂载到/mnt/md0
然后df查看一下是否挂载成功并测试是否可写进文件
目前为止raid0就算构建完了,现在他的存储速度就要快了很多
为了长久使用这个raid设备,可将它写进fstab
[root@myserver root]# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
/dev/md0 /mnt/md0 ext3 defaults 0 0
[root@myserver root]# raidstop /dev/md0 –停止raid0设备工作,停止前要先卸载/dev/md0
[root@myserver root]# lsraid -A -a /dev/md0 –查看raid设备中硬盘工作状态,是否有坏盘
—————————————– ———————————–
raid1、raid5和raid0构建类似,不过需要注意:
1,因为raid1是做数据镜像,所以构建raid1需要的硬盘数为偶数
2,因为raid5是做数据校验,所以构建raid5需要的硬盘数为至少三块
3,采用对应的示范配置文件,raid1就取raid1.conf.sample,raid5就取raid5.conf.sample,按实际情况修改它