虚拟机上的RAID5构建练手(3)

下载完成后,解压缩,编译,安装

[root@ SOURCES]# tar -zxvf mdadm-3.0.tar.gz

[root@ mdadm-3.0]# make

[root@ mdadm-3.0]# make install

mdadm安装完成后,仅生成一个可执行程序mdadm,RAID的所有操作都通过该程序实现。这也是mdadm的方便之处。

第三步 配置RAID5

创建RAID采用create选项(可以先使用mdadm --help熟悉下mdadm的选项和参数),查看帮助

[root@ /]# mdadm --create --help
Usage:  mdadm --create device -chunk=X --level=Y --raid-devices=Z devices

This usage will initialise a new md array, associate some
 devices with it, and activate the array.   In order to create an
 array with some devices missing, use the special word 'missing' in
 place of the relevant device name.

Before devices are added, they are checked to see if they already contain
 raid superblocks or filesystems.  They are also checked to see if
 the variance in device size exceeds 1%.
 If any discrepancy is found, the user will be prompted for confirmation
 before the array is created.  The presence of a '--run' can override this
 caution.

If the --size option is given then only that many kilobytes of each
 device is used, no matter how big each device is.
 If no --size is given, the apparent size of the smallest drive given
 is used for raid level 1 and greater, and the full device is used for
 other levels.

Options that are valid with --create (-C) are:
  --bitmap=          : Create a bitmap for the array with the given filename
  --chunk=      -c   : chunk size of kibibytes
  --rounding=        : rounding factor for linear array (==chunk size)
  --level=      -l   : raid level: 0,1,4,5,6,linear,multipath and synonyms
  --parity=     -p   : raid5/6 parity algorithm: {left,right}-{,a}symmetric
  --layout=          : same as --parity
  --raid-devices= -n : number of active devices in array
  --spare-devices= -x: number of spares (eXtras) devices in initial array
  --size=       -z   : Size (in K) of each drive in RAID1/4/5/6/10 - optional
  --force       -f   : Honour devices as listed on command line.  Don't
                     : insert a missing drive for RAID5.
  --run         -R   : insist of running the array even if not all
                     : devices are present or some look odd.
  --readonly    -o   : start the array readonly - not supported yet.
  --name=       -N   : Textual name for array - max 32 characters
  --bitmap-chunk=    : bitmap chunksize in Kilobytes.
  --delay=      -d   : bitmap update delay in seconds.

可以看到大部分选项都有简写形式,使用下面的指令创建RAID,指令可以解释为:

-Cv 创建RAID并输出详细信息

/dev/md0 RAID的设备名

-l5 level5即RAID5

-n3 3块激活磁盘/dev/sdb /dev/sdc /dev/sdd

-x1 1块备份盘/dev/sde

[root@ /]# mdadm -Cv /dev/md0 -l5 -n3 /dev/sdb /dev/sdc /dev/sdd -x1 /dev/sde
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 64K
mdadm: size set to 8388544K
mdadm: array /dev/md0 started.
查看创建RAID的结果,可以看到你的RAID的一些信息。

[root@ /]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdd[4] sde[3](S) sdc[1] sdb[0]
      16777088 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_]
      [==>..................]  recovery = 10.4% (876808/8388544) finish=10.7min speed=11636K/sec

第四步 格式化raid

[root@ /]# mkfs.ext2 /dev/md0


第五步 使用RAID

RAID创建完毕后,我的Fedora8系统自动将其挂载到了/media/disk下,如果没有自动挂载的话,需要执行挂载才能使用

[root@ /]# mount /dev/md0 /mnt/raid

然后就可以进行存储了。注意若要系统启动后就可以使用RAID,需要将创建RAID和挂载的指令添加到启动脚本中。另外注意关机前不要忘了卸载RAID。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://127.0.0.1/wyyfxw.html