首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | 服务器技术 | linux相关 | linux认证 | 嵌入式 | 下载中心 | 专题 | linux招聘 | 镜像站
OKLinux中文技术站
·设为首页
·加入收藏
·联系我们
系统管理: 中文环境 系统管理 桌面应用 内核技术 | Linux基础: 基础入门 安装配置 常用命令 经验技巧 软件应用 | Linux数据库: Mysql Postgre Oracle DB2 Sybase other
网络管理: 网络安全 网络应用 Linux服务器 环境配置 黑客安全 | 编程开发: PHP CC++ Python Perl Shell 嵌入式开发 java jsp | PHP技术: PHP基础 PHP技巧 PHP应用 PHP文摘
Linux资讯 Linux招聘 Linux专题 Apache | Linux相关: 硬件相关 Linux解决方案 Linux认证 企业应用 其它Unix | 相关下载: 资料下载 参考手册 开发工具 服务器类 软路由 其它
 技术搜索:
会员中心 注册会员 高级搜索  
  → 当前位置:首页>linux基础>linux其它>正文

在AS4下用mdadm命令创建RAID磁盘阵列

http://www.oklinux.cn  2007-04-04  来源: oklinux收集整理  linux286      会员收藏  游客收藏  【 】 
1.创建4个新raid分区,每个为800M,过程如下:
[root@localhost ~]# fdisk /dev/hda

The number of cylinders for this disk is set to 4864.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1912 15358108+ 7 HPFS/NTFS
/dev/hda2 1913 1937 200812+ 83 Linux
/dev/hda3 1938 3212 10241437+ 83 Linux
/dev/hda4 3213 4864 13269690 5 Extended
/dev/hda5 3213 3722 4096543+ 83 Linux
/dev/hda6 3723 3977 2048256 83 Linux
/dev/hda7 3978 4079 819283+ 83 Linux
/dev/hda8 4080 4144 522081 82 Linux swap

Command (m for help): n
First cylinder (4145-4864, default 4145):
Using default value 4145
Last cylinder or +size or +sizeM or +sizeK (4145-4864, default 4864): +800M

Command (m for help): n
First cylinder (4243-4864, default 4243):
Using default value 4243
Last cylinder or +size or +sizeM or +sizeK (4243-4864, default 4864): +800M

Command (m for help): n
First cylinder (4341-4864, default 4341):
Using default value 4341
Last cylinder or +size or +sizeM or +sizeK (4341-4864, default 4864): +800M

Command (m for help): n
First cylinder (4439-4864, default 4439):
Using default value 4439
Last cylinder or +size or +sizeM or +sizeK (4439-4864, default 4864): +800M

Command (m for help): p

Disk /dev/hda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1912 15358108+ 7 HPFS/NTFS
/dev/hda2 1913 1937 200812+ 83 Linux
/dev/hda3 1938 3212 10241437+ 83 Linux
/dev/hda4 3213 4864 13269690 5 Extended
/dev/hda5 3213 3722 4096543+ 83 Linux
/dev/hda6 3723 3977 2048256 83 Linux
/dev/hda7 3978 4079 819283+ 83 Linux
/dev/hda8 4080 4144 522081 82 Linux swap
/dev/hda9 4145 4242 787153+ 83 Linux
/dev/hda10 4243 4340 787153+ 83 Linux
/dev/hda11 4341 4438 787153+ 83 Linux
/dev/hda12 4439 4536 787153+ 83 Linux

Command (m for help): t
Partition number (1-12): 9
Hex code (type L to list codes): l

0 Empty 1c Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid
1 FAT12 1e Hidden W95 FAT1 75 PC/IX be Solaris boot
2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/sec (FAT-
3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/sec (FAT-
4 FAT16 <32M 3c PartitionMagic 82 Linux swap c6 DRDOS/sec (FAT-
5 Extended 40 Venix 80286 83 Linux c7 Syrinx
6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data
7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / .
8 AIX 4d QNX4.x 86 NTFS volume set de Dell Utility
9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt
a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
b W95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O
c W95 FAT32 (LBA) 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
e W95 FAT16 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
f W95 Ext'd (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
14 Hidden FAT16 <3 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS secondary
17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux raid auto
18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep
1b Hidden W95 FAT3 65 Novell Netware b8 BSDI swap ff BBT
Hex code (type L to list codes): fd
Changed system type of partition 9 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-12): 10
Hex code (type L to list codes): fd
Changed system type of partition 10 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-12): 11
Hex code (type L to list codes): fd
Changed system type of partition 11 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-12): 12
Hex code (type L to list codes): fd
Changed system type of partition 12 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/hda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1912 15358108+ 7 HPFS/NTFS
/dev/hda2 1913 1937 200812+ 83 Linux
/dev/hda3 1938 3212 10241437+ 83 Linux
/dev/hda4 3213 4864 13269690 5 Extended
/dev/hda5 3213 3722 4096543+ 83 Linux
/dev/hda6 3723 3977 2048256 83 Linux
/dev/hda7 3978 4079 819283+ 83 Linux
/dev/hda8 4080 4144 522081 82 Linux swap
/dev/hda9 4145 4242 787153+ fd Linux raid autodetect
/dev/hda10 4243 4340 787153+ fd Linux raid autodetect
/dev/hda11 4341 4438 787153+ fd Linux raid autodetect
/dev/hda12 4439 4536 787153+ fd Linux raid autodetect

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

2。使用mdadm 命令来建立一个 RAID 0 阵列/dev/md0.
[root@localhost ~]# mdadm -C /dev/md0 --level=0 --raid-devices=4 /dev/hda9 /dev/hda10 /dev/hda11 /dev/hda12
mdadm: /dev/hda9 appears to contain an ext2fs file system
size=786432K mtime=Thu Jan 1 08:00:00 1970
mdadm: /dev/hda10 appears to contain an ext2fs file system
size=786432K mtime=Thu Jan 1 08:00:00 1970
mdadm: /dev/hda11 appears to contain an ext2fs file system
size=786432K mtime=Thu Jan 1 08:00:00 1970
mdadm: /dev/hda12 appears to contain an ext2fs file system
size=786432K mtime=Thu Jan 1 08:00:00 1970
Continue creating array? yes
mdadm: array /dev/md0 started.
3.使用mdadm -D命令查看/dev/md0
[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 00.90.01
Creation Time : Sat Nov 19 10:01:47 2005
Raid Level : raid0
Array Size : 3148288 (3.00 GiB 3.22 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent

Update Time : Sat Nov 19 10:01:47 2005
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Chunk Size : 64K

Number Major Minor RaidDevice State
0 3 9 0 active sync /dev/hda9
1 3 10 1 active sync /dev/hda10
2 3 11 2 active sync /dev/hda11
3 3 12 3 active sync /dev/hda12
UUID : da00d68c:ec3e8057:dafaf27a:fb0c2fa3
Events : 0.1
4.(这步可省略,但为了便于以后管理,建议使用)创建mdadm.conf
[root@localhost ~]#echo DEVICE /dev/hd*[0-9] /dev/sd*[0-9] > /etc/mdadm.conf
[root@localhost ~]#mdadm --detail --scan >> /etc/mdadm.conf
5.在新建的raid上创建ext3
[root@localhost ~]# mkfs.ext3 /dev/md0
mke2fs 1.35 (28-Feb-2004)
max_blocks 805961728, rsv_groups = 24596, rsv_gdb = 192
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
393600 inodes, 787072 blocks
39353 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=809500672
25 block groups
32768 blocks per group, 32768 fragments per group
15744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
inode.i_blocks = 9224, i_size = 4243456
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6.挂载raid阵列
[root@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/md0 /data
[root@localhost ~]# cd /data
[root@localhost data]# ls
lost+found
[root@localhost data]# df -H /data
Filesystem 容量 已用 可用 已用% 挂载点
/dev/md0 3.2G 39M 3.0G 2% /data
[root@localhost data]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 hda12[3] hda11[2] hda10[1] hda9[0]
3148288 blocks 64k chunks

unused devices: <none>
[root@localhost ~]#umount /data
7.装配已经存有的阵列
先停止活动的磁盘阵列:
mdadm -S /dev/md0
再装配到/dev/md1:
[root@localhost data]# mdadm -A /dev/md1 /dev/hda9 /dev/hda10 /dev/hda11 /dev/hda12
mdadm: /dev/md1 has been started with 4 drives.
[root@localhost data]# mdadm -D /dev/md1
/dev/md1:
Version : 00.90.01
Creation Time : Sat Nov 19 10:01:47 2005
Raid Level : raid0
Array Size : 3148288 (3.00 GiB 3.22 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 1
Persistence : Superblock is persistent

Update Time : Sat Nov 19 10:01:47 2005
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0

Chunk Size : 64K

Number Major Minor RaidDevice State
0 3 9 0 active sync /dev/hda9
1 3 10 1 active sync /dev/hda10
2 3 11 2 active sync /dev/hda11
3 3 12 3 active sync /dev/hda12
UUID : da00d68c:ec3e8057:dafaf27a:fb0c2fa3
Events : 0.1

怎么样设置热备盘?
mdadm -C /dev/md0 -l5 --raid-devices=3 /dev/sda1 /dev/sda2 /dev/sda3 --spare-device=1 /dev/sda4
/dev/sda4就是 spare devcie

Number Major Minor RaidDevice State
0 8 7 0 active sync /dev/sda7
1 8 8 1 active sync /dev/sda8
2 8 9 2 active sync /dev/sda9
3 8 10 -1 spare /dev/sda10

怎么样热换磁盘?
mdadm /dev/md0 -f /dev/sdax
set faulty for sdax

mdadm /dev/md0 -r /dev/sdax
hot remove /dev/sdax from /dev/md0

mdadm /dev/md0 -a /dev/sdax
hot add /dev/sdax to /dev/md0

if the array is full ,new added /dev/sdax will be a spare device
it'll be auto added when a device in array is down

怎么样删除已有的software raid?
1.stop /dev/mdX:
mdadm -S /dev/mdX
or
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

上一篇:Debian下修改grub的背景   下一篇:LINUX开始咯


收藏于收藏夹】 【评论】 【推荐】 【打印】 【关闭
相关文档
·LINUX开始咯
·Debian下修改grub的背景
·Debian系统的笔记
·linux下u,g,o权限执行的先后
·Ubuntu的由来:非洲富翁要建Linux免费软件平台战微软
·使用ubuntu6.0有感
·好马也吃回头草 Suse Linux创始人重回Novell
·美化Ubuntu的字体
·配置ubuntu上网问题
·debian下改IP并立即生效
·在debian下安装LumaQQ的心路历程
·Ubuntu技巧
·Debian下安装latex
·ubuntu dapper下解决依赖关系安装opera-static
·跟我一步一步地学debian
·ubuntu下安装软件的几种方法
发表评论
密码: 匿名评论
评论内容:

(不超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
 
  最新文档
·Fedora Linux下运行PS2模拟器
·ARM、DSP、FPGA的技术特点和区别是什么
·从我做起,10件可以帮助开源的事
·介绍Linux系统下的几个小游戏模拟器
·了解 Linux Kudzu服务的作用
·Linux操作系统上到底提供了哪些基本软
·Ubuntu下两个项目管理工具:Dia和Plann
·UNIX的分支 服务器上的FreeBSD系统
·Ubuntu下用多个Sources.list文件加速AP
·Linux下各种主要文件系统的读写性能测
·内核循环缓冲区数据结构在用户态的使用
·移植Uboot到ARMer9开发系统上
  阅读排行
·配置ubuntu上网问题
·debian Linux 下 Cedega 使用指南
·SuSE Linux安装后的初步设置
·移植Uboot到ARMer9开发系统上
·ubuntu dapper下解决依赖关系安装opera
·ubuntu中的快捷方式
·解决ubuntu 6.06不能保存DNS地址的问题
·debian Linux下制作deb包的简便方法
·GNU EMACS字体设置,基本上可以随心所
·ubuntu下安装软件的几种方法
·在ubuntu下修改网卡地址
·Linux下使用FrameBuffer直接写屏
·Linux下各种主要文件系统的读写性能测
·Kirin原创的eclipse editor配色方案
·debian Linux大全
网摘收藏: