在rhel4下,用mdadm命令创建RAID磁盘阵列实验
时间:2006-11-03 来源:linuxzhe
标题: 在rhel4下,用mdadm命令创建RAID磁盘阵列实验
--------------------------------------------------------------------------------
在rhel4下,用mdadm命令创建RAID磁盘阵列实验 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 /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
删除已有的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 请问怎么样设置热备盘?
请问怎么样设置热备盘? 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
请问在spare rebuilding 是意思呢?
补充一点点
mdadm 使用参考 mdadm是linux下用于管理软件 raid 的工具 以下内容来自 manpage 页: 基本语法 : mdadm [mode] [options] [mode] 有7种: Assemble:将以前定义的某个阵列加入当前在用阵列。 Build:Build a legacy array ,每个device 没有 superblocks Create:创建一个新的阵列,每个device 具有 superblocks Manage: 管理阵列,比如 add 或 remove Misc:允许单独对阵列中的某个 device 做操作,比如抹去superblocks 或 终止在用的阵列。 Follow or Monitor:监控 raid 1,4,5,6 和 multipath 的状态 Grow:改变raid 容量或 阵列中的 device 数目 可用的 [options]: -A, --assemble:加入一个以前定义的阵列 -B, --build:Build a legacy array without superblocks. -C, --create:创建一个新的阵列 -Q, --query:查看一个device,判断它为一个 md device 或是 一个 md 阵列的一部分 -D, --detail:打印一个或多个 md device 的详细信息 -E, --examine:打印 device 上的 md superblock 的内容 -F, --follow, --monitor:选择 Monitor 模式 -G, --grow:改变在用阵列的大小或形态 -h, --help:帮助信息,用在以上选项后,则显示该选项信息 --help-options -V, --version -v, --verbose:显示细节 -b, --brief:较少的细节。用于 --detail 和 --examine 选项 -f, --force -c, --config= :指定配置文件,缺省为 /etc/mdadm/mdadm.conf -s, --scan:扫描配置文件或 /proc/mdstat以搜寻丢失的信息。配置文件/etc/mdadm/mdadm.conf create 或 build 使用的选项: -c, --chunk=:Specify chunk size of kibibytes. 缺省为 64. --rounding=: Specify rounding factor for linear array (==chunk size) -l, --level=:设定 raid level. --create可用:linear, raid0, 0, stripe, raid1,1, mirror, raid4, 4, raid5, 5, raid6, 6, multipath, mp. --build可用:linear, raid0, 0, stripe. -p, --parity=:设定 raid5 的奇偶校验规则:eft-asymmetric, left-symmetric, right-asymmetric, right-symmetric, la, ra, ls, rs.缺省为left-symmetric --layout=:类似于--parity -n, --raid-devices=:指定阵列中可用 device 数目,这个数目只能由 --grow 修改 -x, --spare-devices=:指定初始阵列的富余device 数目 -z, --size=:组建RAID1/4/5/6后从每个device获取的空间总数 --assume-clean:目前仅用于 --build 选项 -R, --run:阵列中的某一部分出现在其他阵列或文件系统中时,mdadm会确认该阵列。此选项将不作确认。 -f, --force:通常mdadm不允许只用一个device 创建阵列,而且创建raid5时会使用一个device作为missing drive。此选项正相反。 -a, --auto{=no,yes,md,mdp,part,p}{NN}: fff395198695fff
在rhel4下,用mdadm命令创建RAID磁盘阵列实验 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 /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
删除已有的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 请问怎么样设置热备盘?
请问怎么样设置热备盘? 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
请问在spare rebuilding 是意思呢?
补充一点点
mdadm 使用参考 mdadm是linux下用于管理软件 raid 的工具 以下内容来自 manpage 页: 基本语法 : mdadm [mode] [options] [mode] 有7种: Assemble:将以前定义的某个阵列加入当前在用阵列。 Build:Build a legacy array ,每个device 没有 superblocks Create:创建一个新的阵列,每个device 具有 superblocks Manage: 管理阵列,比如 add 或 remove Misc:允许单独对阵列中的某个 device 做操作,比如抹去superblocks 或 终止在用的阵列。 Follow or Monitor:监控 raid 1,4,5,6 和 multipath 的状态 Grow:改变raid 容量或 阵列中的 device 数目 可用的 [options]: -A, --assemble:加入一个以前定义的阵列 -B, --build:Build a legacy array without superblocks. -C, --create:创建一个新的阵列 -Q, --query:查看一个device,判断它为一个 md device 或是 一个 md 阵列的一部分 -D, --detail:打印一个或多个 md device 的详细信息 -E, --examine:打印 device 上的 md superblock 的内容 -F, --follow, --monitor:选择 Monitor 模式 -G, --grow:改变在用阵列的大小或形态 -h, --help:帮助信息,用在以上选项后,则显示该选项信息 --help-options -V, --version -v, --verbose:显示细节 -b, --brief:较少的细节。用于 --detail 和 --examine 选项 -f, --force -c, --config= :指定配置文件,缺省为 /etc/mdadm/mdadm.conf -s, --scan:扫描配置文件或 /proc/mdstat以搜寻丢失的信息。配置文件/etc/mdadm/mdadm.conf create 或 build 使用的选项: -c, --chunk=:Specify chunk size of kibibytes. 缺省为 64. --rounding=: Specify rounding factor for linear array (==chunk size) -l, --level=:设定 raid level. --create可用:linear, raid0, 0, stripe, raid1,1, mirror, raid4, 4, raid5, 5, raid6, 6, multipath, mp. --build可用:linear, raid0, 0, stripe. -p, --parity=:设定 raid5 的奇偶校验规则:eft-asymmetric, left-symmetric, right-asymmetric, right-symmetric, la, ra, ls, rs.缺省为left-symmetric --layout=:类似于--parity -n, --raid-devices=:指定阵列中可用 device 数目,这个数目只能由 --grow 修改 -x, --spare-devices=:指定初始阵列的富余device 数目 -z, --size=:组建RAID1/4/5/6后从每个device获取的空间总数 --assume-clean:目前仅用于 --build 选项 -R, --run:阵列中的某一部分出现在其他阵列或文件系统中时,mdadm会确认该阵列。此选项将不作确认。 -f, --force:通常mdadm不允许只用一个device 创建阵列,而且创建raid5时会使用一个device作为missing drive。此选项正相反。 -a, --auto{=no,yes,md,mdp,part,p}{NN}: fff395198695fff
相关阅读 更多 +