MDADM建立軟RIAD

1.對磁盤進行分區,分區類型爲fd.(fdisk /dev/sdb )app

Disk /dev/sdb: 21.5 GB, 21474836480 byteside

255 heads, 63 sectors/track, 2610 cylindersspa

Units = cylinders of 16065 * 512 = 8225280 bytesit

Sector size (logical/physical): 512 bytes / 512 bytesio

I/O size (minimum/optimal): 512 bytes / 512 bytesclass

Disk identifier: 0x00050060sed


   Device Boot      Start         End      Blocks   Id  Systemobject

/dev/sdb1               1         654     5253223+  fd  Linux raid autodetectdate

/dev/sdb2             655        1308     5253255   fd  Linux raid autodetectmap

/dev/sdb3            1309        1962     5253255   fd  Linux raid autodetect

/dev/sdb4            1963        2355     3156772+  fd  Linux raid autodetect


2.用mdadm建立riad.

  mdadm -C /dev/md0 -l 5 -n 3 -x 1 /dev/sdb{1,2,3,4}

    -C 建立模式

    -l riad模式

    -n 建立raid的設備數量

    -x 空閒設備數量

   查看建立好的raid

   [root@bogon ~]# cat /proc/mdstat 

   Personalities : [raid6] [raid5] [raid4] 

   md0 : active raid5 sdb3[4] sdb4[3](S) sdb2[1] sdb1[0]

      10498048 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]


3.建立文件系統

   mkfs.ext4 /dev/md0

   [root@bogon ~]# blkid /dev/md0

   /dev/md0: UUID="1e839796-01a6-4635-bef4-f1cbad3097d4" TYPE="ext4" 



4.掛載到目錄使用

   mount /dev/md0 /mnt

[root@bogon ~]# mount

/dev/mapper/VolGroup-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

/dev/md0 on /mnt type ext4 (rw)

!若是須要開機自動掛載的話須要修改/etc/fstab


5.人爲損壞一塊硬盤查看備份盤是否會替換損壞的盤。

   mdadm -f /dev/md0 /dev/sdb2

   [root@bogon ~]# mdadm -D /dev/md0

/dev/md0:

        Version : 1.2

  Creation Time : Tue Dec 27 05:11:20 2016

     Raid Level : raid5

     Array Size : 10498048 (10.01 GiB 10.75 GB)

  Used Dev Size : 5249024 (5.01 GiB 5.38 GB)

   Raid Devices : 3

  Total Devices : 4

    Persistence : Superblock is persistent


    Update Time : Tue Dec 27 05:48:06 2016

          State : clean 

 Active Devices : 3

Working Devices : 4

 Failed Devices : 0

  Spare Devices : 1


         Layout : left-symmetric

     Chunk Size : 512K


           Name : bogon:0  (local to host bogon)

           UUID : 2f52c38f:0e9eb247:d8a6537c:dc76facf

         Events : 39


    Number   Major   Minor   RaidDevice State

       0       8       17        0      active sync   /dev/sdb1

       3       8       20        1      active sync   /dev/sdb4

       4       8       19        2      active sync   /dev/sdb3


       5       8       18        -      spare   /dev/sdb2



6.添加一塊新的盤做爲備份盤

   mdadm  -a  /dev/md0 /dev/sdb2

相關文章
相關標籤/搜索