[root@localhost ~]uname �Ca
Linux zzsrv2.bigcloud.local 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@localhost ~]# mkfs.ext3 /dev/sdb
修改类型为fd
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
[root@localhost ~]# mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@localhost ~]# mkfs.ext3 /dev/md0
写入配置
[root@localhost ~]# mdadm --detail --scan >> /etc/mdadm.conf
[root@localhost ~]# cat /proc/mdstat
\Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdd1[3] sdc1[1] sdb1[0]
41895936 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_]
[=>...................] recovery = 9.5% (1991296/20947968) finish=7.2min speed=43472K/sec
unused devices: <none>
挂载
[root@localhost ~]# mkdir /data/
[root@localhost ~]# mount /dev/md0 /data
[root@localhost ~]# ll /data/
total 16
drwx------ 2 root root 16384 Aug 5 11:16 lost+found
[root@localhost data]# vi /etc/fstab
在末尾添加如下内容,设置成为默认启动
/dev/md0 /data ext4 defaults 0 0
建立文件实验
[root@localhost ~]# cd /data
[root@localhost data]# touch 123
[root@localhost data]# touch 1234
在虚拟机外先把sdb1移除.再进命令行敲
[root@localhost ~]# mdadm /dev/md0 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
.
[root@localhost data]# mdadm /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1 from /dev/md0
[root@localhost ~]# reboot
[root@localhost ~]# mdadm /dev/md0 --add /dev/sdb1
ndadm:added/dev/sdb1
[root@localhost ~]# ll /data
total 16
drwx------ 2 root root 16384 Aug 6 16:47 lost+found
-rw-r--r-- 1 root root 0 Aug 6 16:48 q1
-rw-r--r-- 1 root root 0 Aug 6 16:49 q2
-rw-r--r-- 1 root root 0 Aug 6 16:49 q3
-rw-r--r-- 1 root root 0 Aug 6 16:53 q4
本文出自 “李景祥” 博客,谢绝转载!