挂载RHEL6.5的安装光盘
[root@leaus ~]# mount /dev/cdrom/mnt/cdrom/ mount: block device /dev/sr0 iswrite-protected, mounting read-only [root@leaus ~]# cd /mnt/cdrom/Packages/ 使用rpm命令安装mdadm [root@leaus Packages]# rpm -ivhmdadm-3.2.5-4.el6.x86_64.rpm Preparing... ########################################### [100%] package mdadm-3.2.5-4.el6.x86_64 is already installed |
[root@leaus Packages]# rpm -qa mdadm mdadm-3.2.5-4.el6.x86_64 [root@leaus Packages]# rpm -qc mdadm /etc/cron.d/raid-check /etc/sysconfig/raid-check |
察看磁盘和分区
[root@leaus ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x0006c28a Device Boot Start End Blocks Id System /dev/sda1 * 1 131 1048576 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 131 2742 20971520 83 Linux /dev/sda3 2742 4047 10485760 83 Linux /dev/sda4 4047 5222 9436160 5 Extended /dev/sda5 4048 4309 2097152 82 Linux swap / Solaris 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 |
以上共有四个分区,其中/dev/sda 为系统盘,剩余三个盘用于配置RAID5卷
格式化硬盘
raid分区类型为fd
具体操作为
[root@leaus ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x27088e01. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won‘t be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to switch off the mode (command ‘c‘) and change display units to sectors (command ‘u‘). Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): Value out of range. Partition number (1-4): 1 First cylinder (1-2610, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): Using default value 2610 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) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
依次对/dev/sdb、/dev/sdc、/dev/sdd进行格式化操作
建立raid5卷
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd 察看磁盘分区 会发现多出来一个分区 Disk /dev/md0: 42.9 GB, 42915069952 bytes 2 heads, 4 sectors/track, 10477312 cylinders Units = cylinders of 8 * 512 = 4096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 524288 bytes / 1048576 bytes Disk identifier: 0x00000000
格式化RAID5卷
[root@leaus ~]# mkfs.ext4 /dev/md0 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=128 blocks, Stripe width=256 blocks 2621440 inodes, 10477312 blocks 523865 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 320 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 把raid5卷加入启动 [root@leaus ~]# mdadm --detail --scan >> /etc/mdadm.conf [root@leaus ~]# cat /proc/mdstat 查看raid5完成 Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sdd[3] sdc[1] sdb[0] 41909248 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_] [========>............] recovery = 44.6% (9351040/20954624) finish=2.2min speed=85136K/sec unused devices: <none> |
在RAID5 上创建LVM卷
创建PV [root@leaus /]# pvcreate /dev/md0 Physical volume "/dev/md0" successfully created 创建VG [root@leaus /]# vgcreate t1 /dev/md0 Volume group "t1" successfully created 创建LV [root@leaus /]# lvcreate -L 20G -n file1 t1 Logical volume "file1" created 格式化LV [root@leaus /]# mkfs.ext4 /dev/t1/file1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=128 blocks, Stripe width=256 blocks 1310720 inodes, 5242880 blocks 262144 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 24 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. 挂载LV分区 [root@leaus /]# mount /dev/t1/file1 /root/data [root@leaus /]# cd /root/data/ [root@leaus data]# ll total 16 drwx------. 2 root root 16384 Aug 14 20:25 lost+found 写入文件 [root@leaus /]# cd /root/data/ [root@leaus data]# touch 123.txt [root@leaus data]# touch 456.txt |
察看硬盘损坏后的磁盘系统
缺少了/dev/sdd
[root@leaus ~]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sdb[1] sdc[3] 41909248 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU] unused devices: <none> |
[root@leaus ~]# cd /root/data/ [root@leaus data]# ll total 16 -rw-r--r--. 1 root root 0 Aug 14 20:34 123.txt -rw-r--r--. 1 root root 0 Aug 14 20:34 456.txt drwx------. 2 root root 16384 Aug 14 20:25 lost+found |
RAID5的Rebuild
去掉损坏硬盘
mdadm /dev/md0 --fail /dev/sdb1 让坏硬盘在raid中失效 mdadm /dev/md0 --remove /dev/sdb1 移除坏硬盘 |
察看分区表
[root@leaus ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x0006c28a Device Boot Start End Blocks Id System /dev/sda1 * 1 131 1048576 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 131 2742 20971520 83 Linux /dev/sda3 2742 4047 10485760 83 Linux /dev/sda4 4047 5222 9436160 5 Extended /dev/sda5 4048 4309 2097152 82 Linux swap / Solaris 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: 0xf770fa99 Device Boot Start End Blocks Id System /dev/sdb1 1 2610 20964793+ fd Linux raid autodetect 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: 0xb1a21bfd Device Boot Start End Blocks Id System /dev/sdc1 1 2610 20964793+ fd Linux raid autodetect 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 Disk /dev/md0: 42.9 GB, 42915069952 bytes 2 heads, 4 sectors/track, 10477312 cylinders Units = cylinders of 8 * 512 = 4096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 524288 bytes / 1048576 bytes Disk identifier: 0x00000000 Disk /dev/mapper/t1-file1: 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): 524288 bytes / 1048576 bytes Disk identifier: 0x00000000 |
将/dev/sdd进行格式化
参考之前进行的格式化过程
在RAID5中添加硬盘
[root@leaus ~]#mdadm /dev/md0 --add /dev/sdd [root@leaus ~]察看RAID5的同步完成情况 #cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sdd[4] sdb[1] sdc[3] 41909248 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU] [=>...................] recovery = 8.0% (1682688/20954624) finish=2.2min speed=140224K/sec unused devices: <none> |
磁盘同步成功以后,察看磁盘文件是否丢失
[root@leaus ~]# mount /dev/mapper/t1-file1 /root/data/ [root@leaus ~]# cd /root/data [root@leaus data]# ll total 16 -rw-r--r--. 1 root root 0 Aug 14 20:34 123.txt -rw-r--r--. 1 root root 0 Aug 14 20:34 456.txt drwx------. 2 root root 16384 Aug 14 20:25 lost+found |
RHEL6.5 配置 RAID5下的 LVM卷,布布扣,bubuko.com
原文地址:http://leaus.blog.51cto.com/9273485/1540183