Disk management-RAID 0

Source: Internet
Author: User
Tags deprecated
1. What is raid0?

Raid0, which divides data into several halves and writes data to multiple disks A: A1 A2 ...... Performance improvement. At least two disks are required.

 

Merge multiple disks into a large disk with no redundancy and parallel I/O, with the fastest speed. RAID 0 is also called a zone set. It associates multiple disks to form a large disk. When storing data, the data is segmented by the number of disks and written into these disks at the same time. Therefore, RAID 0 is the fastest among all levels. However, RAID 0 does not have redundancy. If a disk (physical) is damaged, all data will be lost, which is similar to jbod.

 

Theoretically, the higher the disk performance is equal to "single disk performance" × "Number of disks", but it is actually affected by bus I/O bottlenecks and other factors, raid efficiency decreases along with the margin. That is to say, if the performance of a disk is 50 MB per second, the RAID 0 performance of two disks is about 96 MB per second, the RAID 0 of the three disks may be MB per second rather than MB per second. Therefore, the RAID 0 of the two disks can greatly improve the efficiency.

 

However, if raid is implemented using software, the disk space is not necessarily limited (such as Linux software raid ), all disk space can be utilized through different combinations through software implementation.

 

2. raid0 demonstration

Step 1: partition the disk

[Root @ serv01/] # ls/dev/sdb/dev/SDB [root @ serv01/] # ls/dev/SDC [root @ serv01/] # ls /dev/SDB */dev/SDC *-lbrw-RW ----. 1 root disk 8, 16 Jul 31 23: 20/dev/sdbbrw-RW ----. 1 root disk 8, 17 Jul 31/dev/sdb1brw-rw ----. 1 root disk 8, 32 Jul 31 23: 21/dev/sdcbrw-RW ----. 1 root disk 8, 33 Jul 31/dev/sdc1 # partition: Only one partition (/dev/sdb). Change the partition type to FD (T, FD) # Linux raid autodetect: FD [root @ serv01/] # FDI SK/dev/SDB # partition: Only one partition (/dev/SDC). Change the partition type to FD (T, FD) [root @ serv01/] # fdisk/dev/SDC [root @ serv01/] # fdisk-L | grep-e SDB-esdcdisk/dev/SDB: 2147 MB, 2147483648 Bytes/dev/sdb1 1 261 2096451 FD Linux raid autodetectdisk/dev/SDC: 2147 MB, 2147483648 Bytes/dev/sdc1 1 261 2096451 FD Linux raid autodetect # Install mdadm-Implementation of Soft Raid [root @ serv01/] # Yum install/sbin/mdadm-y [root @ serv01 /] # ls/dev/SDB */dev/SD B/dev/sdb1 [root @ serv01/] # ls/dev/SDC */dev/SDC/dev/sdc1 # create raid [root @ serv01/] # mdadm -- create/ dev/md0 -- level 0 -- raid-devices = 2/dev/sdb1/dev/sdc1mdadm: /dev/sdb1 appears to contain anext2fs file system size = 208812 K mtime = Wed Jul 3122: 17: 43 2013 mdadm:/dev/sdb1 appears to be part of araid array: level = raid0 devices = 0 ctime = Thu Jan 1 07:00:00 1970 mdadm: Partition Table exists on/dev/sdb1but Will be lost or meaningless after creating arraycontinue creating array? Ymdadm: defaulting to version 1.2 metadatamdadm: array/dev/md0 started. [root @ serv01/] # ls/dev/md0/dev/md0 # View Details of/dev/md0 [root @ serv01/] # mdadm -- detail/dev/md0/ dev/md0: version: 1.2 Creation Time: Wed Jul 31 23:30:26 2013 raid level: raid0 array size: 4190208 (4.00 gib 4.29 GB) raid devices: 2 Total devices: 2 Persistence: superblock is persistent Update Time: Wed Jul 31 23:30:26 2013 State: Clean active devices: 2 working devices: 2 failed devices: 0 spare devices: 0 chunk size: 512 K name: serv01.host.com: 0 (localto host serv01.host.com) UUID: 1f1a007f: 7ed82aa0: 49722d2f: 1e664330 events: 0 Number major minor raiddevice state 0 8 17 0 Active Sync/dev/sdb1 1 1 8 33 1 Active Sync/dev/sdc1 [root @ serv01/] # Cat/proc/mdstatpersonalities: [raid0] md0: Active raid0 sdc1 [1] sdb1 [0] 4190208 blocks super 1.2 512 K chunks unused devices: <none>

Step 2 format

[root@serv01 /]# mkfs.ext4 /dev/md0mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=128 blocks, Stripe width=256 blocks262144 inodes, 1047552 blocks52377 blocks (5.00%) reserved for the superuserFirst data block=0Maximum filesystem blocks=107374182432 block groups32768 blocks per group, 32768 fragments pergroup8192 inodes per groupSuperblock backups stored on blocks:       32768,98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: done                           Creating journal (16384 blocks): mdoneWriting superblocks and filesystemaccounting information: done This filesystem will be automaticallychecked every 26 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@serv01 /]# mount /dev/md0 /web/[root@serv01 /]# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/sda2             9.7G  1.1G 8.1G  12% /tmpfs                 188M     0 188M   0% /dev/shm/dev/sda1             194M   25M 160M  14% /boot/dev/sda5             4.0G  137M 3.7G   4% /opt/dev/sr0              3.4G  3.4G    0 100% /iso/dev/md0              4.0G   72M 3.7G   2% /web [root@serv01 /]# vim /etc/fstab[root@serv01 /]# echo "/dev/md0 /webext4 defaults 1 2" >> /etc/fstab[root@serv01 /]# cat /etc/fstab ## /etc/fstab# Created by anaconda on Tue Jul 2300:54:37 2013## Accessible filesystems, by reference, aremaintained under '/dev/disk'# See man pages fstab(5), findfs(8),mount(8) and/or blkid(8) for more info#UUID=110fab7c-85c4-4bae-9114-98bc2ada24d8/                       ext4    defaults        1 1UUID=ab434325-bf02-48e9-8ce7-78494a8ac71e/boot                   ext4    defaults        1 2UUID=02ed2b3b-b7e1-493d-9a43-8e1dcac8aa6f/opt                    ext4    defaults        1 2UUID=a088a35a-16d8-456a-a177-95c769c16e41swap                    swap    defaults        0 0tmpfs                   /dev/shm                tmpfs   defaults        0 0devpts                  /dev/pts                devpts  gid=5,mode=620  0 0sysfs                   /sys                    sysfs   defaults        0 0proc                    /proc                   proc   defaults        0 0/dev/md0 /web ext4 defaults 1 2

 

Step 3 resolve the rename after restart and demonstrate the raid0 Application

# Restart and find an error # check and find that the name has been changed to [root @ serv01 ~] # Ls/dev/mdmd/md127 [root @ serv01 ~] # Mdadm -- manage/dev/md127 -- stopmdadm: stopped/dev/md127 [root @ serv01 ~] # Ls/dev/mdmd-device-map [root @ serv01 ~] # Mdadm -- datail/dev/md0mdadm: Unrecognized option '-- datail 'usage: mdadm -- help forhelp # Check the raid status and find that [root @ serv01 ~] is not used # Cat/proc/mdstatpersonalities: [raid0] unused devices: <none> # fixed name, then start raid [root @ serv01 ~] # Mdadm -- assemble/dev/md0/dev/sdb1/dev/sdc1mdadm:/dev/md0 has been started with 2drives. # check the status of [root @ serv01 ~] # Cat/proc/mdstatpersonalities: [raid0] md0: Active raid0 sdb1 [0] sdc1 [1] 4190208 blocks super 1.2 K chunks unused devices: <none> # Save raid information to the configuration file [root @ serv01 ~] # Mdadm -- detail-scan>/etc/mdadm. conf # enter the mounting information of the device [root @ serv01 ~] # Echo "/dev/md0/webext4 defaults 1 2">/etc/fstab # restart [root @ serv01 ~] # Reboot [root @ larrywen 0731] # SSH 192.168.1.11root@192.168.1.11's password: Last login: Wed Jul 31 23:43:44 2013 from192.168.1.1 [root @ serv01 ~] # DF-hfilesystem size used avail use % mounted on/dev/sda2 9.7g 1.1G 8.1g 12%/tmpfs 188 M 0 188 m 0%/dev/SHM/dev/sda1 194 m 25 m 160 m 14%/boot/dev/sda5 4.0g 137 m 3.7g 4%/opt/dev/md0 4.0g 72 m 3.7g 2%/web/dev/sr0 3.4g 3.4G 0 100%/ISO [root @ serv01 ~] # Cat/proc/mdstatpersonalities: [raid0] md0: Active raid0 sdb1 [0] sdc1 [1] 4190208 blocks super 1.2 K chunks unused devices: <none> # [root @ serv01 ~] # Ls/dev/mdmd/md0 # the disk size is different. For example, if one disk is 1 GB and the other is 2 GB, only 1 GB # raid0 is actually useful: the other part is broken and cannot be used [root @ serv01 ~]. # DF-hfilesystem size used avail use % mounted on/dev/sda2 9.7g 1.1G 8.1g 12%/tmpfs 188 M 0 188 m 0%/dev/SHM/dev/sda1 194 m 25 m 160 m 14%/boot/dev/sda5 4.0g 137 m 3.7g 4%/opt/dev/md0 4.0g 72 m 3.7g 2%/web/dev/sr0 3.4g 3.4G 0 100%/ISO [root @ serv01 ~] # Fdisk/dev/SDB warning: DOS-compatible mode is deprecated. it's stronugly recommended to switch off the mode (command 'C') and change display units to sectors (command 'U '). command (M for help): p Disk/dev/SDB: 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/opti MAL): 512 bytes/512 bytesdisk identifier: 0xf85ef5bd device boot start end blocks ID system/dev/sdb1 1 1 261 FD Linux raid autodetect command (M for help ): obuilding a new dos disklabel with diskidentifier 0xc29e300a. 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 partitiontabl E 4 will be corrected by W (RITE) Warning: DOS-compatible mode is deprecated. it's stronugly 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 ~] # Fdisk-L |/dev/sdb1-bash:/dev/sdb1: permission denieddisk/dev/SDD doesn't contain a validpartition tabledisk/dev/SDE doesn't contain a validpartition tabledisk/dev/SDF doesn't contain a category tabledisk/dev/SDG doesn't contain a validpartition tabledisk/dev/md0 doesn't contain a validpartition table [root @ serv01 ~] # Fdisk-L |/dev/SDB-Bash:/dev/SDB: permission denieddisk/dev/SDD doesn't contain a validpartition tabledisk/dev/SDE doesn't contain a validpartition tabledisk/dev/SDF doesn't contain a category tabledisk/dev/SDG doesn't contain a validpartition tabledisk/dev/md0 doesn' t contain a validpartition table # Check whether the repair mode is enabled after restart # Remount the root partition Mount-O remount, RW/# Delete the configured raid, then restart # re-view, and find that raid is no longer available [root @ l Arrywen 0731] # SSH 192.168.1.11root@192.168.1.11's password: Last login: Wed Jul 31 23:49:41 2013 from192.168.1.1 [root @ serv01 ~] # Cat/proc/mdstatpersonalities: [raid0] md0: inactive sdc1 [1] 2095104 blocks super 1.2 unused devices: <none> [root @ serv01 ~] # DF-hfilesystem size used avail use % mounted on/dev/sda2 9.7g 1.1G 8.1g 12%/tmpfs 188 M 0 188 m 0%/dev/SHM/dev/sda1 194 m 25 m 160 m 14%/boot/dev/sda5 4.0g 137 m 3.7g 4%/opt/dev/sr0 3.4g 3.4g 0 100%/ISO [root @ serv01 ~] # Mdadm -- detail/dev/mdmd/md0 [root @ serv01 ~] # Mdadm -- detail/dev/md0/dev/md0: Version: 1.2 Creation Time: Wed Jul 31 23:30:26 2013 raid level: raid0 raid devices: 2 Total devices: 1 Persistence: superblock is persistent Update Time: Wed Jul 31 23:30:26 2013 State: active, failed, not started active devices: 1 working devices: 1 failed devices: 0 spare devices: 0 Chunk Size: 512 K name: serv01.host.com: 0 (localto host serv01.host.com) UUID: 1f1a007f: 7ed82aa0: 49722d2f: 1e664330 events: 0 Number major minor raiddevice state 0 0 0 0 removed 1 8 33 1 Active Sync/dev/sdc1

Step 4 finish the experiment and clear the disk

# Perform the following operations to clean up data and perform raid: # Stop raid [root @ serv01 ~] # Mdadm -- manage/dev/md0 -- stopmdadm: stopped/dev/md0 [root @ serv01 ~] # Rm-RF/etc/mdadm. conf [root @ serv01 ~] # Mdadm-E/dev/sdb1mdadm: cannot open/dev/sdb1: no such fileor directory # residual information detected [root @ serv01 ~] # Mdadm-E/dev/sdc1/dev/sdc1: Magic: a92b4efc version: 1.2 Feature Map: 0x0 array UUID: Signature: 7ed82aa0: 49722d2f: 1e664330 name: serv01.host.com: 0 (localto host serv01.host.com) Creation Time: Wed Jul 31 23:30:26 2013 raid level: raid0 raid devices: 2 avail Dev size: 4190854 (2046.66 MIB 2145.72 MB) Data offset: 2048 sectors super offset: 8 sectors state: clean device UUID: 7e3d4caf: 3 5001960: b95d9ski: 19fa3093 Update Time: Wed Jul 31 23:30:26 2013 checksum: 64b18466-correct events: 0 chunk size: 512 K device role: active device 1 array state: AA ('A' = active ,'. '= Missing) # Clear the disk [root @ serv01 ~] # Mdadm -- MISC-Zero-superblock/dev/sdc1 [root @ serv01 ~] # Fdisk/dev/SDB warning: DOS-compatible mode is deprecated. it's stronugly recommended to switch off the mode (command 'C') andchange display units to sectors (command 'U '). command (M for help): ncommand Action E extended P primary partition (1-4) ppartition number (1-4): 1 first cylinder (1-261, default 1 ): using default value 1 last cylinder, + cylinders or + size {K, M, g} (1-261, default 261): Using defau Lt value 261 command (M for help): wthe partition table has been altered! Calling IOCTL () to re-read Partition Table. syncing disks. [root @ serv01 ~] # Mdadm-E/dev/sdb1/dev/sdb1: Magic: a92b4efc version: 1.2 Feature Map: 0x0 array UUID: Signature: 7ed82aa0: 49722d2f: 1e664330 name: serv01.host.com: 0 (localto host serv01.host.com) Creation Time: Wed Jul 31 23:30:26 2013 raid level: raid0 raid devices: 2 avail Dev size: 4190854 (2046.66 MIB 2145.72 MB) Data offset: 2048 sectors super offset: 8 sectors state: clean device UUID: f76937d2: 7 4ac3af1: 506bed88: 795c81ed Update Time: Wed Jul 31 23:30:26 2013 checksum: 4d5dcd15-correct events: 0 chunk size: 512 K device role: active device 0 array state: AA ('A' = active ,'. '= Missing) # Clear the disk [root @ serv01 ~] # Mdadm -- MISC -- zero-superblock/dev/sdb1mdadm: couldn't open/dev/sdb1 for write-not zeroing [root @ serv01 ~] # Cat/proc/mdstatpersonalities: [raid0] md0: inactive sdb1 [0] (s) 2095427 blocks super 1.2 unused devices: <none> root @ serv01 ~] # Mdadm -- manage/dev/md0 -- stopmdadm: stopped/dev/md0 [root @ serv01 ~] # Mdadm -- MISC -- zero-superblock/dev/sdb1 [root @ serv01 ~] # [Root @ serv01 ~] # Mdadm-E/dev/sdb1/dev/sdb1: MBR magic: aa55 [root @ serv01 ~] # Mdadm-E/dev/sdc1mdadm: no MD superblock detected on/dev/sdc1.

3. References

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

4. Related Articles

  • Disk management-Raid 1

  • Disk management-raid 10
  • Disk management-RAID 5
My mailbox: wgbno27@163.com Sina Weibo: @ wentasy27 public platform: justoracle (No.: justoracle) database technology exchange group: 336882565 (when adding group verification from csdn XXX) Oracle Exchange discussion group: https://groups.google.com/d/forum/justoracleBy Larry Wen
 
@ Wentasy blog is for your reference only. Welcome to visit. I hope to criticize and correct any mistakes. If you need to repost the original blog post, please indicate the source. Thank you for the [csdn blog]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.