software raid linux,linux software raid 相关

(转自[url]http://tonykorn97.itpub.net/post/6414/466843[/url] 作者:tonykorn97)

1,software RAID Configuration

Create and define RAID devices using mdadm

mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/sda1 /dev/sdb1 /dev/sdc1

-l: raid级别

-n: 硬盘数

-x: 热备份硬盘数

format each RAID device with a filesystem

mke2fs -j /dev/md0

test the RAID devices

mdadm allows you to check the status of your RAID devices

mdadm --detail /dev/md0

2,software RAID testing and recovery

simulating disk failures

mdadm /dev/md0 -f /dev/sda1

(模拟sda1硬盘坏 )

recovering from a software RAID disk failure

replace the failed hard drive and power on

reconstruct partitions on the replacement drive

增加新硬盘

mdadm /dev/md0 -a /dev/sda1

删除硬盘

mdadm /dev/md0 -r /dev/sda1

mdadm,/proc/mdstat,and syslog messages

例子:

1,准备的分区信息

/dev/sda5 1864 1988 1004031 83 Linux

/dev/sda6 1989 2113 1004031 83 Linux

/dev/sda7 2114 2238 1004031 83 Linux

2,建立阵列

[root@tonykorn97 ~]# mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/sda{5,6,7}

mdadm: /dev/sda5 appears to contain an ext2fs file system

size=1004028K mtime=Sun May 18 06:03:36 2008

Continue creating array? y

mdadm: array /dev/md0 started.

此时fdisk 可以查看到/dev/md0分区

[root@tonykorn97 ~]# fdisk -l

...

Disk /dev/md0: 1027 MB, 1027997696 bytes

2 heads, 4 sectors/track, 250976 cylinders

Units = cylinders of 8 * 512 = 4096 bytes

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

3,格式化分区并挂载

[root@tonykorn97 ~]# mkfs.ext3 /dev/md0

...

[root@tonykorn97 ~]# mkdir /data

[root@tonykorn97 ~]# mount /dev/md0 /data

4,查看当前raid信息

[root@tonykorn97 ~]# mdadm --detail /dev/md0

/dev/md0:

Version : 00.90.03

Creation Time : Sun Jul 13 10:15:49 2008

Raid Level : raid1

Array Size : 1003904 (980.54 MiB 1028.00 MB)

Device Size : 1003904 (980.54 MiB 1028.00 MB)

Raid Devices : 2

Total Devices : 3

Preferred Minor : 0

Persistence : Superblock is persistent

Update Time : Sun Jul 13 10:17:27 2008

State : clean

Active Devices : 2

Working Devices : 3

Failed Devices : 0

Spare Devices : 1

UUID : 95695625:471aa8d7:1d74ab8c:1224f36e

Events : 0.2

Number Major Minor RaidDevice State

0 8 5 0 active sync /dev/sda5

1 8 6 1 active sync /dev/sda6

2 8 7 - spare /dev/sda7

[root@tonykorn97 ~]#

4,模拟一个硬盘坏

[root@tonykorn97 ~]# mdadm --fail /dev/md0 /dev/sda5

mdadm: set /dev/sda5 faulty in /dev/md0

此时raid的状态

[root@tonykorn97 ~]# mdadm --detail /dev/md0

/dev/md0:

Version : 00.90.03

Creation Time : Sun Jul 13 10:15:49 2008

Raid Level : raid1

Array Size : 1003904 (980.54 MiB 1028.00 MB)

Device Size : 1003904 (980.54 MiB 1028.00 MB)

Raid Devices : 2

Total Devices : 3

Preferred Minor : 0

Persistence : Superblock is persistent

Update Time : Sun Jul 13 10:20:03 2008

State : clean, degraded, recovering

Active Devices : 1

Working Devices : 2

Failed Devices : 1

Spare Devices : 1

Rebuild Status : 41% complete

UUID : 95695625:471aa8d7:1d74ab8c:1224f36e

Events : 0.4

Number Major Minor RaidDevice State

2 8 7 0 spare rebuilding /dev/sda7

1 8 6 1 active sync /dev/sda6

3 8 5 - faulty spare /dev/sda5

[root@tonykorn97 ~]# cat /proc/mdstat

Personalities : [raid1]

md0 : active raid1 sda7[2] sda6[1] sda5[3](F)

1003904 blocks [2/1] [_U]

[============>........] recovery = 64.6% (649344/1003904) finish=0.2min speed=20946K/sec

unused devices:

[root@tonykorn97 ~]#

阵列用备用盘代替坏掉硬盘后的状态:

[root@tonykorn97 ~]# mdadm --detail /dev/md0

/dev/md0:

Version : 00.90.03

Creation Time : Sun Jul 13 10:15:49 2008

Raid Level : raid1

Array Size : 1003904 (980.54 MiB 1028.00 MB)

Device Size : 1003904 (980.54 MiB 1028.00 MB)

Raid Devices : 2

Total Devices : 3

Preferred Minor : 0

Persistence : Superblock is persistent

Update Time : Sun Jul 13 10:20:53 2008

State : clean

Active Devices : 2

Working Devices : 2

Failed Devices : 1

Spare Devices : 0

UUID : 95695625:471aa8d7:1d74ab8c:1224f36e

Events : 0.6

Number Major Minor RaidDevice State

0 8 7 0 active sync /dev/sda7

1 8 6 1 active sync /dev/sda6

2 8 5 - faulty spare /dev/sda5

[root@tonykorn97 ~]#

移出这个出问题的磁盘:

[root@tonykorn97 ~]# mdadm --remove /dev/md0 /dev/sda5

mdadm: hot removed /dev/sda5

[root@tonykorn97 ~]# mdadm --detail /dev/md0

/dev/md0:

Version : 00.90.03

Creation Time : Sun Jul 13 10:15:49 2008

Raid Level : raid1

Array Size : 1003904 (980.54 MiB 1028.00 MB)

Device Size : 1003904 (980.54 MiB 1028.00 MB)

Raid Devices : 2

Total Devices : 2

Preferred Minor : 0

Persistence : Superblock is persistent

Update Time : Sun Jul 13 10:23:11 2008

State : clean

Active Devices : 2

Working Devices : 2

Failed Devices : 0

Spare Devices : 0

UUID : 95695625:471aa8d7:1d74ab8c:1224f36e

Events : 0.8

Number Major Minor RaidDevice State

0 8 7 0 active sync /dev/sda7

1 8 6 1 active sync /dev/sda6

[root@tonykorn97 ~]#

添加硬盘

[root@tonykorn97 ~]# mdadm -a /dev/md0 /dev/sda5

mdadm: added /dev/sda5

You have new mail in /var/spool/mail/root

[root@tonykorn97 ~]# mdadm --detail /dev/md0

/dev/md0:

Version : 00.90.03

Creation Time : Sun Jul 13 10:15:49 2008

Raid Level : raid1

Array Size : 1003904 (980.54 MiB 1028.00 MB)

Device Size : 1003904 (980.54 MiB 1028.00 MB)

Raid Devices : 2

Total Devices : 3

Preferred Minor : 0

Persistence : Superblock is persistent

Update Time : Sun Jul 13 10:23:45 2008

State : clean

Active Devices : 2

Working Devices : 3

Failed Devices : 0

Spare Devices : 1

UUID : 95695625:471aa8d7:1d74ab8c:1224f36e

Events : 0.8

Number Major Minor RaidDevice State

0 8 7 0 active sync /dev/sda7

1 8 6 1 active sync /dev/sda6

2 8 5 - spare /dev/sda5

[root@tonykorn97 ~]#

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值