分类: LINUX
2008-09-24 11:43:42
RAID5:
mdadm是一个全新的raid管理工具,rhel LINUX版本 >= RHEL4.
要求:需要在三块硬盘上创建RAID5 并挂载到 /raid5disk 目录下!
先用fdisk -l 看一下三块磁盘的设备号,在这里就是
/dev/sdb /dev/sdc /dev/sdd
1. 首先在三块硬盘上分别创建一个分区!
# fdisk /dev/sdb Command (m for help): n 按n创建新分区 Command action e extended p primary partition (1-4) 输入p 选择创建主分区 Partition number (1-4): 输入 1 创建第一个主分区 First cylinder (1-204, default1): 直接回车,选择分区开始柱面这里就从 1 开始 Last cylinder or +size or +sizeM or+sizeK (1-204, default 204):
也是直接回车,最后一个柱面!我这里是204, 各人的硬盘大小不一样大,这里的值也不一样大! 这样就将硬盘1柱面到204柱面创建了第一个主分区!
Command (m for help): t 输入t 指定分区类型! Selected partition 1 Hex code (type L to listcodes):
可以直接输入fd,指定分区类型就为Linux raid auto 也可以输入l看一下所有支持的分区类型! 我这里倒数第三个就是raid的分区类型代号为fd
Command (m for help): w 然后输入w写盘! The partition table has been altered! Calling ioctl() to re-read partitiontable. Syncing disks.
按照此步骤在另外的两块磁盘上做同样的操作! 全部做完后,运行 fdisk -l 应该可以看到如下信息!
Disk /dev/sdb: 214 MB, 214748160 bytes 64 heads, 32 sectors/track, 204 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 204 208880 fd Linux raid autodetect Disk /dev/sdc: 214 MB, 214748160 bytes 64 heads, 32 sectors/track, 204 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 204 208880 fd Linux raid autodetect Disk /dev/sdd: 214 MB, 214748160 bytes 64 heads, 32 sectors/track, 204 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdd1 1 204 208880 fd Linux raid autodetect
看到上面三个磁盘上分别建了一个分区,分区大小都一样! 然后再运行
#mdadm -Cv /dev/md0 -l5 -n3 /dev/sdb1 /dev/sdc1 /dev/sdd1
这里就在三个分区上创建了raid5 软件陈列, 新的分区设备号为md0 然后格式化一下md0分区
[root@localhost ~]# mkfs.ext3 /dev/md0 mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 104448 inodes, 417536 blocks 20876 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 51 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801,221185, 401409 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
根据分区大小一样,这里需要的时间也会不一样!
然后在 #mkdir /raid5disk 在/上建一个目录raid5disk 然后用mount 将md0挂上去! #mount /dev/md0 /raid5disk/ 好了,试试到raiddisk目录建几个文件! 为了让系统重新启动后自动挂载,可以修改一下/etc/fstab文件,添加一行! /dev/md0 /raid5disk auto defaults 0 0 这样系统重新启动后会自动将/dev/md0挂接到 /raid5disk目录下! 好了!一切OK! 再查看一下md0的状态!
[root@localhost ~]# mdadm -D /dev/md0 /dev/md0:
Version : 00.90.01 Creation Time : Tue Feb 28 22:10:41 2006 Raid Level : raid5 Array Size : 417536 (407.75 MiB 427.56 MB) Device Size : 208768 (203.88 MiB 213.78 MB) Raid Devices : 3 Total Devices : 3
Preferred Minor : 0
Persistence : Superblock is persistent Update Time : Tue Feb 28 22:17:55 2006 State : clean
Active Devices : 3 Working Devices : 3 Failed Devices : 0
Spare Devices : 0 Layout :left-symmetric Chunk Size : 64K Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 UUID : 70fc89c1:ef191858:784578eb:81603b8d Events : 0.48
一切正常!
备注:
删除已有的software raid:
1.stop /dev/mdX: mdadm -S /dev/mdX 或者rm /dev/mdX
2.del/etc/mdadm.conf
3.del raid mount in /etc/fstab and autofs
4.del raid part use fdisk or parted