linux 软raid 稳定性,linux下软raid的实现

有两个可以实现软raid的工具:raidtools, mdadm。

raidtool,这是在RHEL3中所使用的,但是我在RHEL4中没有找到raidtool,只有mdadm,看来RH也是偏向于使用mdadm的。

本文也以mdadm为例讲述。

一、查看当前硬盘情况

[root@primary /]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 1114 8843782+ 83 Linux

/dev/sda3 1115 1305 1534207+ 82 Linux swap

Disk /dev/sdb: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Disk /dev/sdc doesn't contain a valid partition table

二、为硬盘分区

raid一般多个硬盘来组成,你也可以用同一个硬盘的多个分区组成raid,但这样是没有意义的。

[root@primary /]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-102, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-102, default 102):

Using default value 102

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@primary /]# fdisk /dev/sdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-102, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-102, default 102):

Using default value 102

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

此时硬盘的分区情况:

[root@primary /]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 * 1 13 104391 83 Linux

/dev/sda2 14 1114 8843782+ 83 Linux

/dev/sda3 1115 1305 1534207+ 82 Linux swap

Disk /dev/sdb: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 102 104432 83 Linux

Disk /dev/sdc: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id System

/dev/sdc1 1 102 104432 83 Linux

三、创建raid0

[root@primary /]# mdadm --create /dev/md0 --level=raid0 --chunk=8 --raid-devices=2 /dev/sdb1 /dev/sdc1

四、生成mdadm配置文件

mdadm的缺省配置文件为/etc/mdadm.conf,它主要是为了方便阵列的日常管理而设置的,对于阵列而言不是必须的,但是为了减少日后管理中不必要的麻烦,还是应该坚持把这一步做完。

在mdadm.conf文件中要包含两种类型的行:一种是以DEVICE开头的行,它指明在阵列中的设备列表;另一种是以ARRAY开头的行,它详细地说明了阵列的名称、模式、阵列中活动设备的数目以及设备的UUID号。

我们可以用mdadm -Ds来得到mdadm.conf文件需要的信息:

[root@primary ~]# mdadm -Ds

ARRAY /dev/md0 level=raid0 num-devices=2 UUID=63f24968:d367038d:f207e458:9a803df9

devices=/dev/sdb1,/dev/sdc1

根据上面的信息编辑/etc/mdadm.conf,如下:

[root@primary ~]# more /etc/mdadm.conf

ARRAY /dev/md0 level=raid0 num-devices=2 UUID=63f24968:d367038d:f207e458:9a803df9

device /dev/sdb1 /dev/sdc1

如果不配置这个文件,在重启后尝试mount raid设备的时候会报错:

[root@primary ~]# mount /dev/md0 /opt

/dev/md0: Invalid argument

mount: /dev/md0: can't read superblock

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值