In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to set up RAID 10 in Linux system to ensure high performance and fault-tolerant disk input / output". In the operation of practical cases, many people will encounter this dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The RAID 10 (also known as RAID 1 strip 0 or mirror stripe) array combines the features of both RAID 0 and RAID 1 to provide high-performance, fault-tolerant disk input / output operations. In RAID 0, read / write operations are performed in parallel across multiple drives; in RAID 1, identical data is written to two or more drives.
In this tutorial, I will show you 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 4 (such as a set of striped two mirrors), we will add an additional spare drive in case one of the primary drives fails. We will also introduce some tools that you can use to analyze the performance of RAID arrays later.
Please note that a comprehensive and in-depth introduction to all the pros and cons of RAID 10 and other partitioning schemes (as well as drives and file systems of different sizes) is beyond the scope of this article.
How does the RAID 10 array work?
If you need to implement a storage solution that supports input / output-intensive operations such as databases, e-mail, and web servers, RAID 10 is the right choice. The reason for this will be described below. You might as well take a look at the following picture.
Stripes of Mirror 1 and Mirror 2
Imagine that a file consists of blocks A, B, C, D, and E in the figure above. Each RAID 1 mirror set, such as Mirror 1 or Mirror 2, copies blocks to each of the two devices. As a result of this configuration, write performance is degraded because each data block is written twice, once per disk, and read performance remains unchanged compared to reading data from a single read-only disk. The advantage is that this scheme provides redundancy because normal disk input / output operations can be maintained unless multiple disks in each mirror fail.
RAID 0 stripe works by dividing the data into multiple data blocks and writing block A to mirror 1 and block B to mirror 2, and so on, thus improving overall read and write performance. On the other hand, none of the mirrors contain complete information about any part of the data submitted to the main set. This means that if one of the mirrors fails, the entire RAID 0 component (and therefore the RAID 10 set) becomes inoperable and the data is irreparably lost.
Building RAID 10 Array
There are two possible scenarios for building RAID 10 arrays: complex scenarios (which can be built in one step) or nested scenarios (by building two or more RAID 1 arrays and then using them as component devices in RAID 0). In this tutorial, we will introduce you to building a complex RAID 10 array because it allows us to use an odd or even number of disks and can be managed as a single RAID device, rather than introducing a nesting scheme (only an even number of drives are allowed and must be managed as nested devices, RAID 1 and RAID 0 are handled separately).
Suppose you have installed mdadm and the daemon runs on your system. For more information, see this tutorial: http://xmodulo.com/create-software-raid1-array-mdadm-linux.html. Also 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 look like this:
Next, use the following command to build an 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 build process should take less than a few minutes), the output of # mdadm-- detail / dev/md0 should look like this:
There are several points that need to be explained before we move on to the next step.
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. In the case of RAID 10 arrays, this is equivalent to (NumberC) / M, where N is the number of active devices, C is the capacity of active devices, and M is the number of devices in each mirror. So here, (NumC) / M is equivalent to (4*8GiB) / 2 = 16GiB.
3. Layout refers to the details of data layout. The possible layout values are shown below.
N (default option): means near copy. Multiple copies of a data block are in a similar offset in different devices. This layout provides read and write performance similar to that of the RAID 0 array.
O indicates the offset copy. Instead of replicating the data segment in the stripe, the entire stripe is replicated, but is rotated by one device, so that repetitive data blocks are distributed across different devices. Therefore, the subsequent data block is copied in the next drive, moving down one segment. If you want your RAID 10 array to use this layout, add-- layout=o2 to the command used to build the array.
F indicates a far copy (offsets multiple copies that are completely different). This layout provides good read performance, but poor write performance. Therefore, this scheme is most suitable for systems that need to support much more read operations than write operations. If you want your RAID 10 array to use this layout, add-- layout=f2 to the command used to build the array.
The numbers followed by n, f, and o in the layout option indicate the number of copies of each block required. The default value is 2, but it can be twice the number of devices on disk. By providing a sufficient number of copies, you can minimize the input / output impact of a single drive.
4. Chunk Size, according to the Linux RAID wiki, segment size (chunk size) refers to the smallest unit of data written to the device. The optimized segment size depends on the speed of input / output operations and the size of related files. If you write to large files, you can expect to see lower overhead as long as you make sure that the segments are quite large, while arrays that mainly store small files are expected to benefit more from smaller segments. To specify a segment size for your RAID 10 array, add-- chunk=desired_chunk_size to the command used to build the array.
Unfortunately, there is no one-size-fits-all way to improve performance. Here are a few guidelines worth considering.
File system: overall, XFS is said to be the best file system, while EXT4 is still a good choice.
Optimized layout: far layouts improve read performance, but slow write performance.
Number of copies: more copies minimize input / output impact, but increase costs when more disks are needed.
Hardware: solid state drives are more likely to show improved performance than traditional rotating disks (in the same environment).
Use DD to test RAID performance
The following benchmark tests can be used to verify the performance of our RAID 10 array (/ dev/md0).
1. Write operation
A single file the size of 256MB is written to the device:
# dd if=/dev/zero of=/dev/md0 bs=256M 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 flag, dd bypasses the system file cache and performs synchronous writes to the RAID array. This option is used to eliminate the caching effect during RAID performance testing.
two。 Read operation
256KiB*15000 (3.9 GB) is copied from the array to / dev/null:
# dd if=/dev/md0 of=/dev/null bs=256K count=15000
Use Iozone to test RAID performance
Iozone (http://www.iozone.org) is a file system benchmark tool that allows us to measure a wide range of disk input / output operations, including random read / write, sequential read / write, and reread / rewrite. 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 performs all tests in the RAID-10 array:
# iozone-Ra / dev/md0-b / tmp/md0.xls
-R: generate Excel-compliant reports and send them to standard output devices.
-a: run iozone in fully automatic mode, covering all tests and possible record / file sizes. Record size: 4k to 16m, file size: 64k to 512m.
-b / tmp/md0.xls: stores the test results in a specified file.
This is the end of "how to set up RAID 10 in Linux systems to ensure high performance and fault tolerant disk input / output". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.