Configure RAID10 in Linux

Source: Internet
Author: User
RAID10 (also called RAID1 + 0 or image strip) array combines the features of RAID0 and RAID1 to provide high-performance, fault-tolerant disk input/output operations. In RAID0, read/write operations are performed across multiple drives concurrently; in RAID1, identical data is written to two or more drives. In this tutorial, I will introduce how to build a software RAID 10 array using five identical 8GiB disks. Although it is used to build RAID1

The RAID 10 (also called RAID 1 + 0 or image strip) array combines the features of RAID 0 and RAID 1 to provide high-performance, fault-tolerant disk input/output operations. In RAID 0, read/write operations are performed across multiple drives concurrently; in RAID 1, identical data is written to two or more drives.

In this tutorial, I will introduce how to build a software RAID 10 array using five identical 8 GiB disks. Although the maximum number of disks used to build a RAID 10 array is four (for example, a group of two striped images), we will add an additional backup drive, in case of a primary drive failure. We will also introduce some tools that you can use to analyze the performance of RAID arrays in the future.

Note: all the advantages and disadvantages of RAID 10 and other partitioning schemes (and drive and file systems of different sizes) are not covered in this article.

How does a RAID 10 array work?

If you need to implement a storage solution that supports input/output-intensive operations (such as databases, emails, and website servers), RAID 10 is the right option. The following describes the source Committee. Take a look.

Image 1 and image 2

Suppose A file is composed of data blocks A, B, C, D, and E. Each RAID 1 image set (such as image 1 or image 2) copies data blocks to each of the two devices. Due to this configuration, the write performance is reduced because each data block is written twice and each disk is written once. compared with reading data from a single read disk, the read performance remains unchanged. This solution provides redundancy because disk input/output operations can be maintained unless multiple disks in each image fail.

The principle of RAID 0 strip is to divide data into multiple data blocks, write data block A to Image 1, write data block B to image 2, and so on, this improves the overall read and write performance. On the other hand, no image contains the complete information of any part of the data submitted to the master set. This means that if one of the images fails, the entire RAID 0 component (and therefore the RAID 10 set) will not be able to operate and data will be lost.

Build a RAID 10 array

There are two possible building schemes for RAID 10 arrays: a complex scheme (which can be built in one step) or a nested scheme (the building method is to first build two or more RAID 1 arrays, use them as component devices in RAID 0 ). In this tutorial, we will introduce how to build a complex RAID 10 array, because this array allows us to use an odd or even number of disks, it can also be managed as a single RAID device, rather than introducing a nested solution (only a number of even drives are allowed and must be managed as a nested device. RAID 1 and RAID 0 can be managed separately ).

Assume that you have installed mdadm and the background program runs on your system. For more information, see http://xmodulo.com/create-software-raid1-array-mdadm-linux.html. In addition, assume that the primary partition sd [bcdef] 1 has been created on each disk. Therefore, the output of ls-l/dev | grep sd [bcdef] should be as follows:

Run the following command to build a RAID 10 array:

# Mdadm -- create -- verbose/dev/md0 -- level = 10 -- raid-devices = 4/dev/sd [bcde] 1 -- spare-devices = 1/dev/sdf1

After the array is built (the building process should take several minutes), # The output of mdadm -- detail/dev/md0 should be like this:

Before proceeding to the next step, we need to describe several points.

1. Used Dev Space indicates the capacity of each member device Used by the array.

2. Array Size refers to the total Size of the Array. For RAID 10 arrays, this is equivalent to (N * C)/M, where N refers to the number of active devices and C refers to the capacity of active devices, M indicates the number of devices in each image. So here, (N * C)/M is equivalent to (4*8GiB)/2 = 16GiB.

3. Detailed Layout index data Layout. Possible layout values are as follows.

• N (default option): indicates the near copy. Multiple copies of a data block are at a similar offset in different devices ). The read and write performances provided by this layout are similar to those of RAID 0 arrays.

• O indicates offset copy. Instead of copying data segments in the strip, the whole strip is replicated, but rotated by a device, so that duplicate data blocks are distributed across different devices. Therefore, the subsequent data blocks are copied to the next drive and moved down one data segment. To use this layout for your RAID 10 array, add -- layout = o2 to the command used to build the array.

• F indicates far copy (multiple copies with different offsets ). This layout provides good read performance, but provides poor write performance. Therefore, this solution is most suitable for systems that require much more read operations than write operations. To use this layout for your RAID 10 array, add -- layout = f2 to the command used to build the array.

In the -- layout option, the numbers following n, f, and o indicate the number of copies of each data block. The default value is 2, but it can be a multiple of the number of devices on the disk. By providing enough copies, you can minimize the impact of input/output on a single drive.

4. Chunk Size. based on the Linux RAID wiki, the chunk size refers to the minimum unit of data written to the device. The optimal data segment size depends on the speed of input/output operations and the size of related files. If a large file is written, as long as the data segment is large, it is expected to see a low overhead, and the array that stores small files is expected to benefit more from smaller data segments. To specify the size of a data segment for your RAID 10 array, add -- chunk = desired_chunk_size to the command used to build the array.

Unfortunately, there are no comprehensive methods to improve performance. The following are several guiding principles worth consideration.

• File system: in general, XFS is said to be the best file system, while EXT4 is still a good choice.

• Optimal layout: The far layout improves read performance but reduces write performance.

• Number of replicas: more replicas minimize the impact of input/output, but also increase costs when more disks are needed.

• Hardware: Solid State Disks are more likely to show performance advantages (in the same environment) than traditional rotating disks ).

Test RAID performance using DD

The following benchmark tests can be used to check the performance of our RAID 10 arrays (/dev/md0.

1. write operation

A single file of MB is written to the device:

# Dd if =/dev/zero of =/dev/md0 bs = 256 M count = 1 oflag = dsync

512 bytes are written 1000 times:

# Dd if =/dev/zero of =/dev/md0 bs = 512 count = 1000 oflag = dsync

Due to the dsync mark, dd bypasses the system file cache and synchronously writes data to the RAID array. This option is used to eliminate the cache effect during RAID performance testing.

2. read operations

256KiB * 15000 (3.9 GB) copy from array to/dev/null:

# Dd if =/dev/md0 of =/dev/null bs = 256 K count = 15000

Test RAID performance using Iozone

Iozone (http://www.iozone.org) is a file system benchmark testing tool that allows us to measure numerous disk input/output operations, including random read/write, sequential read/write, and re-read/re-write. It can export the results to Microsoft Excel or LibreOffice Calc files.

Install Iozone on CentOS/RHEL 7

Enable the Repoforge software library, and then execute the following command:

# Yum install iozone

Install Iozone on Debian 7

# Aptitude install iozone3

The following iozone command will execute all tests in the RAID-10 array:

# Iozone-Ra/dev/md0-B/tmp/md0.xls

•-R: generate Excel-compatible reports and send them to standard output devices.

•-A: run iozone in fully automated mode, covering all tests and possible Records/file sizes. Record size: 4 K to 16 M, file size: 64 K to 512 M.

•-B/tmp/md0.xls: Stores test results in a specified file.

I hope this article is helpful. If you have any ideas or tips for improving the performance of RAID 10, please contact us.

Related Article

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.