第六步 添加磁盘
#添加另一个磁盘
[root@serv01 web]# fdisk /dev/sdd
[root@serv01 web]# ls /dev/sdd
sdd sdd1
[root@serv01 web]# mdadm --manage /dev/md1--add /dev/sdd1
mdadm: added /dev/sdd1
[root@serv01 web]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdd1[2] sdc1[1]
2095415 blocks super 1.2 [2/1] [_U]
[=========>...........] recovery = 47.7% (1000064/2095415) finish=0.0min speed=250016K/sec
unused devices: <none>
[root@serv01web]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdd1[2] sdc1[1]
2095415 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@serv01web]# reboot
[root@larrywenDesktop]# ssh 192.168.1.11
root@192.168.1.11's password:
Last login: Thu Aug 1 18:08:05 2013 from 192.168.1.1
[root@serv01 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdd1[2] sdc1[1]
2095415 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@serv01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 1.1G 8.1G 12% /
tmpfs 188M 0 188M 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sda5 4.0G 137M 3.7G 4% /opt
/dev/md1 2.0G 54M 1.9G 3% /web
/dev/sr0 3.4G 3.4G 0 100% /iso
[root@serv01 ~]# mdadm --detail /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Thu Aug 117:58:09 2013
Raid Level : raid1
Array Size : 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Thu Aug 1 18:18:482013
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : serv01.host.com:1 (localto host serv01.host.com)
UUID :a8930aef:a5ddcdde:789a11bf:40f7eed6
Events : 60
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
1 8 33 1 active sync /dev/sdc1
#不重启添加磁盘
#干掉/dev/sdc,o
[root@serv01 ~]# fdisk /dev/sdc
#查看详细信息,发现没坏
[root@serv01 ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Thu Aug 117:58:09 2013
Raid Level : raid1
Array Size : 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Thu Aug 1 18:24:242013
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : serv01.host.com:1 (localto host serv01.host.com)
UUID : a8930aef:a5ddcdde:789a11bf:40f7eed6
Events : 60
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
1 8 33 1 active sync /dev/sdc1
#拷贝文件也不能看到
[root@serv01 ~]# cp /etc/inittab /web
#查看详细信息
[root@serv01 ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Thu Aug 117:58:09 2013
Raid Level : raid1
Array Size : 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Thu Aug 1 18:27:312013
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : serv01.host.com:1 (localto host serv01.host.com)
UUID : a8930aef:a5ddcdde:789a11bf:40f7eed6
Events : 60
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
1 8 33 1 active sync /dev/sdc1
#标志/dev/sdc1错误
root@serv01 ~]# mdadm --manage /dev/md1--fail /dev/sdc1
mdadm: set /dev/sdc1 faulty in /dev/md1
#查看状态
[root@serv01 ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Thu Aug 117:58:09 2013
Raid Level : raid1
Array Size : 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Thu Aug 1 18:28:312013
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
Name : serv01.host.com:1 (localto host serv01.host.com)
UUID : a8930aef:a5ddcdde:789a11bf:40f7eed6
Events : 61
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
1 0 0 1 removed
1 8 33 - faulty spare /dev/sdc1
[root@serv01 ~]# fdisk /dev/sde
#添加/dev/sde1硬盘
[root@serv01 ~]# mdadm --manage /dev/md1--add /dev/sde1
mdadm: added /dev/sde1
#查看详细信息
[root@serv01 ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Thu Aug 117:58:09 2013
Raid Level : raid1
Array Size : 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Thu Aug 1 18:29:562013
State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 1
Spare Devices : 1
Rebuild Status : 85% complete
Name : serv01.host.com:1 (localto host serv01.host.com)
UUID : a8930aef:a5ddcdde:789a11bf:40f7eed6
Events : 80
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
3 8 65 1 spare rebuilding /dev/sde1
1 8 33 - faulty spare /dev/sdc1
#移除磁盘
[root@serv01 ~]# mdadm --manage /dev/md1--remove /dev/sdc1
mdadm: hot removed /dev/sdc1 from /dev/md1
[root@serv01 ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Thu Aug 117:58:09 2013
Raid Level : raid1
Array Size : 2095415 (2046.65 MiB 2145.70 MB)
Used Dev Size : 2095415 (2046.65 MiB 2145.70 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Thu Aug 1 18:30:092013
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : serv01.host.com:1 (local to host serv01.host.com)
UUID : a8930aef:a5ddcdde:789a11bf:40f7eed6
Events : 87
Number Major Minor RaidDevice State
2 8 49 0 active sync /dev/sdd1
3 8 65 1 active sync /dev/sde1
第七步 实验完毕,清空磁盘
[root@serv01 ~]# umount /dev/md1
#停掉
[root@serv01 ~]# mdadm --manage /dev/md1--stop
mdadm: stopped /dev/md1
#删除配置文件
[root@serv01 ~]# rm -rf /etc/mdadm.conf
[root@serv01 ~]# fdisk -l |grep -e sdb -esdc -e sdd -e sde
Disk /dev/sdf doesn't contain a validpartition table
Disk /dev/sdg doesn't contain a validpartition table
Disk /dev/sdb: 2147 MB, 2147483648 bytes
Disk /dev/sdc: 2147 MB, 2147483648 bytes
Disk /dev/sdd: 2147 MB, 2147483648 bytes
Disk /dev/sde: 2147 MB, 2147483648 bytes
#清除磁盘
[root@serv01 ~]# mdadm --misc—zero-superblock /dev/sdb1
[root@serv01 ~]# fdisk /dev/sdb
#清除磁盘
[root@serv01 ~]# mdadm --misc—zero-superblock /dev/sdc1
[root@serv01 ~]# fdisk /dev/sdc
三 相关文章
磁盘管理——RAID 0 http://www.linuxidc.com/Linux/2013-08/88577.htm
