码迷,mamicode.com
首页 > 系统相关 > 详细

Linux RAID5+备份盘测试

时间:2017-08-02 13:06:45      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:工作   meta   block   磁盘   etc   sync   tmpfs   ide   strong   

RAID5磁盘阵列组技术至少需要3块盘来做,加上1块备份盘(这块硬盘设备平时是闲置状态不用工作,一旦RAID磁盘阵列组中有硬盘出现故障后则会马上自动顶替上去),总共是需要向虚拟机中模拟4块硬盘设备。

[root@victory ~]# fdisk -l

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006ae1e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448    10485759     4934656   8e  Linux LVM

Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/rhel-root: 3976 MB, 3976200192 bytes, 7766016 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/rhel-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

现在来创建一个RAID5磁盘阵列组+备份盘,-n 3参数代表创建这个RAID5所需的硬盘个数,-l 5参数代表RAID磁盘阵列的级别,而-x 1参数则代表有1块备份盘,当查看/dev/md0磁盘阵列组的时候就能看到有一块备份盘在等待中了。

[root@victory ~]# mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 2095104K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@victory ~]# mdadm -D /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Tue Aug  1 23:31:26 2017
     Raid Level : raid5
     Array Size : 4190208 (4.00 GiB 4.29 GB)
  Used Dev Size : 2095104 (2046.34 MiB 2145.39 MB)
   Raid Devices : 3
  Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Tue Aug  1 23:31:39 2017
          State : clean, degraded, recovering 
 Active Devices : 2
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 2

         Layout : left-symmetric
     Chunk Size : 512K

 Rebuild Status : 65% complete

           Name : victory.rusky.com:0  (local to host victory.rusky.com)
           UUID : ca1f08c6:07e51bc7:668168b7:2bb84496
         Events : 11

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       32        1      active sync   /dev/sdc
       4       8       48        2      spare rebuilding   /dev/sdd   --表示正在创建中

       3       8       64        -      spare   /dev/sde

[root@victory ~]# mdadm -D /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Tue Aug  1 23:31:26 2017
     Raid Level : raid5
     Array Size : 4190208 (4.00 GiB 4.29 GB)
  Used Dev Size : 2095104 (2046.34 MiB 2145.39 MB)
   Raid Devices : 3
  Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Tue Aug  1 23:31:47 2017
          State : clean 
 Active Devices : 3
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 512K

           Name : victory.rusky.com:0  (local to host victory.rusky.com)
           UUID : ca1f08c6:07e51bc7:668168b7:2bb84496
         Events : 18

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       32        1      active sync   /dev/sdc
       4       8       48        2      active sync   /dev/sdd

       3       8       64        -      spare   /dev/sde
[root@victory ~]# 

把这块制作的RAID5磁盘阵列组格式化为xfs文件格式后挂载到目录上吧,这样就可以使用了。

[root@victory ~]# echo "/dev/md0  /fuckRAID xfs defaults 0 0" >> /etc/fstab
[root@victory ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Aug  1 04:28:47 2017
#
# Accessible filesystems, by reference, are maintained under /dev/disk
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=e7987771-c54c-4b36-8a5c-8e71f129c3fe /boot                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/dev/md0  /fuckRAID xfs defaults 0 0
[root@victory ~]# mkdir /fuckRAID
[root@victory ~]# mount -a
[root@victory ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  3.7G  896M  2.9G  24% /
devtmpfs               910M     0  910M   0% /dev
tmpfs                  920M     0  920M   0% /dev/shm
tmpfs                  920M  8.4M  912M   1% /run
tmpfs                  920M     0  920M   0% /sys/fs/cgroup
/dev/sda1              297M  114M  184M  39% /boot
tmpfs                  184M     0  184M   0% /run/user/0
/dev/md0               4.0G   33M  4.0G   1% /fuckRAID
[root@victory ~]# 

再次把硬盘设备/dev/sdb移出磁盘阵列组,这样快速看下/dev/md0磁盘阵列组的状态就会发现备份盘已经被自动顶替上去,这是非常实用的,在RAID磁盘阵列组数据安全保证的基础上进一步提高数据可靠性。

[root@victory ~]# cd /fuckRAID/
[root@victory fuckRAID]# ll
total 0
[root@victory fuckRAID]# cd ~
[root@victory ~]# cd /fuckRAID/
[root@victory fuckRAID]# touch testaddFile
[root@victory fuckRAID]# ll
total 0
-rw-r--r--. 1 root root 0 Aug  1 23:54 testaddFile
[root@victory fuckRAID]# mdadm /dev/md0 -f /dev/sdb
mdadm: set /dev/sdb faulty in /dev/md0
[root@victory fuckRAID]# mdadm -D /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Tue Aug  1 23:31:26 2017
     Raid Level : raid5
     Array Size : 4190208 (4.00 GiB 4.29 GB)
  Used Dev Size : 2095104 (2046.34 MiB 2145.39 MB)
   Raid Devices : 3
  Total Devices : 4
    Persistence : Superblock is persistent

    Update Time : Tue Aug  1 23:54:43 2017
          State : clean 
 Active Devices : 3
Working Devices : 3
 Failed Devices : 1
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : victory.rusky.com:0  (local to host victory.rusky.com)
           UUID : ca1f08c6:07e51bc7:668168b7:2bb84496
         Events : 41

    Number   Major   Minor   RaidDevice State
       3       8       64        0      active sync   /dev/sde
       1       8       32        1      active sync   /dev/sdc
       4       8       48        2      active sync   /dev/sdd

       0       8       16        -      faulty   /dev/sdb
[root@victory fuckRAID]# ll
total 0
-rw-r--r--. 1 root root 0 Aug  1 23:54 testaddFile
[root@victory fuckRAID]# 

 

Linux RAID5+备份盘测试

标签:工作   meta   block   磁盘   etc   sync   tmpfs   ide   strong   

原文地址:http://www.cnblogs.com/rusking/p/7273173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!