Chinaunix首页 | 论坛 | 博客
  • 博客访问: 693101
  • 博文数量: 139
  • 博客积分: 7607
  • 博客等级: 少将
  • 技术积分: 1964
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-11 23:43
个人简介

...

文章分类

全部博文(139)

文章存档

2012年(53)

2011年(4)

2010年(29)

2009年(10)

2008年(33)

2007年(10)

分类: LINUX

2009-04-08 20:02:47

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 ~]#
阅读(824) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~