- 論壇徽章:
- 0
|
作者:曹程
email:caochengcn@gmail.com
QQ:20754739
mdadm是一個全新的raid管理工具,raidtools需要維護配置文件/etc/raidtab 太麻煩了!
下面就來看看使用 mdadm有多簡單吧!
操作系統(tǒng): RHEL4 updata2 或者CentOS4.2
要求:需要在三塊硬盤上創(chuàng)建RAID5 并掛載到 /raid5disk 目錄下!
先用fdisk -l 看一下三塊磁盤的設備號,在這里就是 /dev/sdb 和 /dev/sdc 以及 /dev/sdd
1. 首先在三塊硬盤上分別創(chuàng)建一個分區(qū)!
# fdisk /dev/sdb
Command (m for help): n 按n創(chuàng)建新分區(qū)
Command action
e extended
p primary partition (1-4) 輸入p 選擇創(chuàng)建主分區(qū)
Partition number (1-4): 輸入 1 創(chuàng)建第一個主分區(qū)
First cylinder (1-204, default 1): 直接回車,選擇分區(qū)開始柱面這里就從 1 開始
Last cylinder or +size or +sizeM or +sizeK (1-204, default 204): 也是直接回車,最后一個柱面!
我這里是204, 各人的硬盤大小不一樣大,這里的值也不一樣大!
這樣就將硬盤1柱面到204柱面創(chuàng)建了第一個主分區(qū)!
Command (m for help): t 輸入t 指定分區(qū)類型!
Selected partition 1
Hex code (type L to list codes): 可以直接輸入fd,指定分區(qū)類型就為Linux raid auto 也可以輸入l
看一下所有支持的分區(qū)類型! 我這里倒數第三個就是raid的分區(qū)類型代號為fd
Command (m for help): w 然后輸入w寫盤!
The partition table has been altered!
Calling ioctl() to re-read partition table.
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
看到上面三個磁盤上分別建了一個分區(qū),分區(qū)大小都一樣!
然后再運行
mdadm -C /dev/md0 -l5 -n3 /dev/sd[bcd]1 這里就在三個分區(qū)上創(chuàng)建了raid5 軟件陳列,
新的分區(qū)設備號為md0
然后格式化一下md0分區(qū)
[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 every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
根據分區(qū)大小一樣,這里需要的時間也會不一樣!
然后在
make /raid5disk 在/上建一個目錄raid5disk
然后用mount 將md0掛上去!
mount /dev/md0 /raid5disk/
好了,試試到raiddisk目錄建幾個文件!
為了讓系統(tǒng)重新啟動后自動掛載,可以修改一下/etc/fstab文件,添加一行!
/dev/md0 /raid5disk auto defaults 0 0
這樣系統(tǒng)重新啟動后會自動將/dev/md0掛接到 /raid5disk目錄下!
好了!一切OK!
再查看一下md0的狀態(tài)!
[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
一切正常!
mdadm是個非常強大,非常棒的的工具,還有好多功能由于時間關系,以后再說!
我QQ:20754739 歡迎交流!
[ 本帖最后由 caocheng 于 2006-2-28 22:24 編輯 ] |
|