Linux disk array technical details (ii)--raid 1 creation

Source: Internet
Author: User

I have described in detail in the Linux disk array technology (a) several types of RAID disk arrays, principles and detailed steps for creating RAID 0. Then this document focuses on how to create a RAID 1 technology:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/8A/F0/wKiom1g_mpLR9lR4AACcfJsTuUc372.png "title=" Qq20161201113140.png "alt=" Wkiom1g_mplr9lr4aaccfjstuuc372.png "/>



The steps are as follows:

① partition

We also take a hard disk of different partitions for example, the actual work should be different hard disk.

Specific partitioning step no longer repeat!

After partitioning the results as shown:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/8A/F0/wKiom1g_m3OTj4twAABVgVdtVK8891.png "title=" Qq20161201113943.png "alt=" Wkiom1g_m3otj4twaabvgvdtvk8891.png "/>


② Creating RAID 1

Mdadm-c-v/dev/md1-l 1-n 2-x 1/DEV/SDC1/DEV/SDC2/DEV/SDC3

Or

Mdadm-c-v/dev/md1-l 1-n 2-x 1/dev/sdc{1,2,3}

Note:-N is followed by 2 because the third hard drive (which is the partition) is a hot spare and not a disk that creates a RAID 1.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8A/F0/wKiom1g_nTbiQ_HrAABlxxNRHdY108.png "title=" Qq20161201114713.png "alt=" Wkiom1g_ntbiq_hraablxxnrhdy108.png "/> also needs to generate a configuration file

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8A/EC/wKioL1g_nerj_JDGAAA4SWnWfUE325.png "title=" Qq20161201115014.png "alt=" Wkiol1g_nerj_jdgaaa4swnwfue325.png "/>


③ partitioning The MD1

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8A/EC/wKioL1g_nqPhajSRAABf2mE7ZK8698.png "title=" Qq20161201115315.png "alt=" Wkiol1g_nqphajsraabf2me7zk8698.png "/>

④ Formatting md1

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/8A/EC/wKioL1g_n0mxUL7iAACgTMRIjhY581.png "title=" Qq20161201115607.png "alt=" Wkiol1g_n0mxul7iaacgtmrijhy581.png "/>


⑤ Mount use

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8A/EC/wKioL1g_n6LBydahAABmeM8nhlY937.png "title=" Qq20161201115735.png "alt=" Wkiol1g_n6lbydahaabmem8nhly937.png "/>



OK, to this RAID 1 is a successful creation!

As I said earlier, RAID 1 is the biggest feature of a hot backup, that is, when one of the disks has a problem and does not result in data loss, then I would like to simulate a disk failure:

First, let's take a look at the configuration file/proc/mdstat get the disk array information:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/8A/F4/wKiom1g_yV2heIoSAAA1MaAmo2M790.png "title=" Qq20161201145308.png "alt=" Wkiom1g_yv2heiosaaa1maamo2m790.png "/>


Comments:

①SDC3[2] (s): where s means spare disk

②[2/2] indicates that two disks in RAID 1 are normal

③active indicates that the array is read and written correctly


Check out the/etc/mdadm.conf configuration file:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/8A/F4/wKiom1g_yoOAt7tcAAAsvKyhS9Y383.png "title=" Qq20161201150030.png "alt=" wkiom1g_yooat7tcaaasvkyhs9y383.png "/> Note: Spares=1 indicates there is a hot spare


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/F5/wKiom1g_yz6y2U91AAETZPRBeFs231.png "title=" Qq20161201150333.png "alt=" Wkiom1g_yz6y2u91aaetzprbefs231.png "/>


First step: Simulate/DEV/SDC1 as a fault disk

At this point, I started a different machine to see the phenomenon in/proc/mdstat:

The command is: Watch-n 1 cat/proc/mdstat dynamic per second refresh

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/8A/F7/wKiom1g_zTHA-PPfAAA-Y_eIb8Q963.png "title=" Qq20161201151149.png "alt=" wkiom1g_ztha-ppfaaa-y_eib8q963.png "/> Watch for changes in the contents of the red box.

Next, the terminal input command

Mdadm-f/DEV/MD1/DEV/SDC1

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/8A/F3/wKioL1g_zZ7gDU5lAAAUE3Vup7o978.png "title=" Qq20161201151335.png "alt=" Wkiol1g_zz7gdu5laaaue3vup7o978.png "/>


And then look at the changes in the content of/proc/mdstat:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8A/F3/wKioL1g_zfChQPTeAAAwax_FTLk271.png "title=" Qq20161201151432.png "alt=" Wkiol1g_zfchqpteaaawax_ftlk271.png "/>


Did you see it? At this point SDC3 has replaced the SDC1 and ensured the integrity of the data.


Step two: Remove the failed disk

Mdadm-r/DEV/MD1/DEV/SDC1

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/8A/F3/wKioL1g_z26j8F9zAAB4_sUr_Ws970.png "title=" Qq20161201152132.png "alt=" Wkiol1g_z26j8f9zaab4_sur_ws970.png "/>

This article is from the "Brother Hong Linux World" blog, so be sure to keep this source http://zhengkangkang.blog.51cto.com/12015643/1878528

Linux disk array technical details (ii)--raid 1 creation

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.