MDADM建立軟RIAD

來源:互聯網
上載者:User

標籤:linux mdadm使用

1.對磁碟進行分區,分區類型為fd.(fdisk /dev/sdb )

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: 0x00050060


   Device Boot      Start         End      Blocks   Id  System

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

/dev/sdb2             655        1308     5253255   fd  Linux raid autodetect

/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

   [[email protected] ~]# 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

   [[email protected] ~]# blkid /dev/md0

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



4.掛載到目錄使用

   mount /dev/md0 /mnt

[[email protected] ~]# 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

   [[email protected] ~]# 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






   


本文出自 “生命不息折騰到底” 部落格,謝絕轉載!

MDADM建立軟RIAD

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.