磁碟管理——RAID 5

來源:互聯網
上載者:User
一 什麼是RAID5

RAID Level 5 是一種儲存效能、資料安全和儲存成本兼顧的儲存解決方案。它使用的是Disk Striping(硬碟分割)技術。RAID 5 至少需要三顆硬碟, RAID 5不是對儲存的資料進行備份,而是把資料和相對應的同位資訊儲存到組成RAID5的各個磁碟上,並且同位資訊和相對應的資料分別儲存於不同的磁碟上。當RAID5的一個磁碟資料發生損壞後,可以利用剩下的資料和相應的同位資訊去恢複被損壞的資料。 RAID 5可以理解為是RAID
0和RAID 1的折衷方案。RAID 5可以為系統提供資料安全保障,但保障程度要比鏡像低而磁碟空間利用率要比鏡像高。RAID 5具有和RAID 0相近似的資料讀取速度,只是因為多了一個同位資訊,寫入資料的速度相當的慢,若使用“回寫快取”可以讓效能改善不少。同時由於多個資料對應一個同位資訊,RAID 5的磁碟空間利用率要比RAID 1高,儲存成本相對較便宜。



 

二 RAID5示範

第一步準備磁碟

[root@serv01 ~]# ls /dev/sdb1 /dev/sdc1/dev/sdd1/dev/sdb1 /dev/sdc1  /dev/sdd1

第二步建立RAID5

[root@serv01 ~]# mdadm --C /dev/md5 —l 5 —n3 /dev/sdb1 /dev/sdc1/ /dev/sdd1[root@serv01 ~]# mdadm --create /dev/md5--level 5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1mdadm: Defaulting to version 1.2 metadatamdadm: array /dev/md5 started.[root@serv01 ~]# cat /proc/mdstatPersonalities : [raid1] [raid0] [raid6][raid5] [raid4]md5 : active raid5 sdd1[3] sdc1[1] sdb1[0]     4190208 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]     unused devices: <none>

第三步 格式化

[root@serv01 ~]# mkfs.ext4 /dev/md5

第四步 修改設定檔

#追加檔案[root@serv01 ~]# echo "/dev/md5 /webext4 defaults 1 2" >> /etc/fstab#建立設定檔[root@serv01 ~]# mdadm --detail --scan >/etc/mdadm.conf             [root@serv01~]# cd /web[root@serv01 web]# lsconfig-2.6.32-131.0.15.el6.x86_64  initramfs-2.6.32-131.0.15.el6.x86_64.img  System.map-2.6.32-131.0.15.el6.x86_64efi                                lost+found                               vmlinuz-2.6.32-131.0.15.el6.x86_64grub                              symvers-2.6.32-131.0.15.el6.x86_64.gz#查看詳細資料[root@serv01 web]# mdadm -D /dev/md5/dev/md5:       Version : 1.2 Creation Time : Thu Aug  119:49:56 2013    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 : 3   Persistence : Superblock is persistent    Update Time : Thu Aug  1 20:24:482013         State : clean Active Devices : 3Working Devices : 3 Failed Devices : 0 Spare Devices : 0         Layout : left-symmetric    Chunk Size : 512K           Name : serv01.host.com:5  (localto host serv01.host.com)          UUID : a738b211:987ef2b2:e6ce9eb3:58724db1        Events : 20    Number   Major   Minor  RaidDevice State      0       8       17       0      active sync   /dev/sdb1      1       8       33       1      active sync   /dev/sdc1      3       8       49       2      active sync   /dev/sdd1

第五步 類比磁碟壞掉

#取消分區 o[root@serv01 web]# fdisk /dev/sdb 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): oBuilding a new DOS disklabel with diskidentifier 0xc785ce7b.Changes will remain in memory only, untilyou decide to write them.After that, of course, the previous contentwon't be recoverable. Warning: invalid flag 0x0000 of partitiontable 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): wThe partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.The kernel still uses the old table. Thenew table will be used atthe next reboot or after you runpartprobe(8) or kpartx(8)Syncing disks.#再次查看[root@serv01 web]# mdadm -D /dev/md5/dev/md5:       Version : 1.2 Creation Time : Thu Aug  119:49:56 2013    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 : 3   Persistence : Superblock is persistent    Update Time : Thu Aug  1 20:25:162013         State : clean Active Devices : 3Working Devices : 3 Failed Devices : 0 Spare Devices : 0         Layout : left-symmetric    Chunk Size : 512K           Name : serv01.host.com:5  (localto host serv01.host.com)          UUID : a738b211:987ef2b2:e6ce9eb3:58724db1        Events : 20    Number   Major   Minor  RaidDevice State      0       8       17       0      active sync   /dev/sdb1      1       8       33       1      active sync   /dev/sdc1      3       8       49       2      active sync   /dev/sdd1 #重啟[root@serv01 web]# reboot#對/dev/sde分區 [root@serv01 web]# fdisk /dev/sde 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): p Disk /dev/sde: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes /512 bytesI/O size (minimum/optimal): 512 bytes / 512bytesDisk identifier: 0x26eb36f1   Device Boot      Start         End      Blocks  Id  System Command (m for help): nCommand action  e   extended  p   primary partition (1-4)pPartition number (1-4): 1First cylinder (1-261, default 1):Using default value 1Last cylinder, +cylinders or +size{K,M,G}(1-261, default 261):Using default value 261 Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.

第六步 添加磁碟

[root@serv01 web]# mdadm --manage /dev/md5--add /dev/sde1mdadm: added /dev/sde1[root@serv01 web]# cat /proc/mdstatPersonalities : [raid6] [raid5] [raid4]md5 : active raid5 sde1[4] sdc1[1] sdd1[3]     4190208 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU]     [=================>...] recovery = 85.8% (1800064/2095104) finish=0.0min speed=200007K/sec     unused devices: <none>#再次查看詳細資料[root@serv01 web]# mdadm --D /dev/md5mdadm: unrecognized option '--D'Usage: mdadm --help  forhelp[root@serv01 web]# mdadm -D /dev/md5/dev/md5:       Version : 1.2 Creation Time : Thu Aug  119:49:56 2013    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 : 3   Persistence : Superblock is persistent    Update Time : Thu Aug  1 20:28:292013         State : clean Active Devices : 3Working Devices : 3 Failed Devices : 0 Spare Devices : 0         Layout : left-symmetric    Chunk Size : 512K           Name : serv01.host.com:5  (localto host serv01.host.com)          UUID : a738b211:987ef2b2:e6ce9eb3:58724db1        Events : 45    Number   Major   Minor  RaidDevice State      4       8       65       0      active sync   /dev/sde1      1       8       33       1      active sync   /dev/sdc1      3       8       49       2      active sync   /dev/sdd1 #重啟後登入root@serv01 web]# reboot [root@larrywen disk]# ssh 192.168.1.11root@192.168.1.11's password:Last login: Thu Aug  1 20:26:07 2013 from 192.168.1.1[root@serv01 ~]# cat /proc/mdstatPersonalities : [raid6] [raid5] [raid4]md5 : active raid5 sdc1[1] sde1[4] sdd1[3]     4190208 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]     unused devices: <none>

三 參考資料

http://zh.wikipedia.org/wiki/RAID

四 相關文章

  • 磁碟管理——RAID 0
  • 磁碟管理——RAID 1
  • 磁碟管理——RAID 10
  我的郵箱:wgbno27@163.com  新浪微博:@Wentasy27           公眾平台:JustOracle(號:justoracle)  資料庫技術交流群:336882565(加群時驗證 From CSDN XXX)  Oracle交流討論群組:https://groups.google.com/d/forum/justoracle  By Larry Wen
 
@Wentasy 博文僅供參考,歡迎大家來訪。如有錯誤之處,希望批評指正。原創博文如需轉載請註明出處,謝謝 [CSDN部落格]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.