Playing with disk arrays in Linux

Source: Internet
Author: User
Article Title: play with the disk array on the Linux operating system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Most users are worried about how to deal with data loss in case of a hard disk failure? In fact, many users will mount more than one hard disk on the host due to hard disk capacity limitations. At this time, if you make these hard disks into a disk array, you can rest assured. A disk array can combine multiple hard disks into one virtual hard disk. In terms of operation, users will feel that it is no different from using a single hard disk. However, in the actual data storage process, the disk array stores data on different hard disks to improve data security. I will talk about how to play with disk arrays in a Linux environment today.

  I. What are the benefits of using a disk array?

Before configuring the disk array, I would like to introduce the advantages of using the disk array. Let's give you some motivation to continue reading the following content.

The first advantage is that the disk array can improve the efficiency of data access. A hard disk is actually like a box with a large internal space, but a small entry and exit. When you want to save a large amount of data in this box, you only need to use this small box to save the data. Its access efficiency is obviously not very high. However, if a disk array is used, when the system writes data to the hard disk, it splits the large data blocks into multiple cells for fast writing and writes them to different hard disks at the same time. This is like opening multiple access holes in a box and adding data to the hole, which can improve the write speed of the hard disk. Similarly, you can read data from different hard disks at the same time to speed up Data Reading. Therefore, disk arrays can improve data storage efficiency. Therefore, deploying disk arrays on some servers can improve the application performance of servers.

The second advantage is that multiple hard disks can be integrated. Most Linux system administrators may have encountered this problem. A hard disk is used, and suddenly the space is insufficient. What should I do now? In fact, the Administrator does not need to change the hard disk. Instead, you can combine multiple small-capacity hard disks into a virtual hard disk with a relatively large capacity. The disk array operation is like a hard disk, so it will not adversely affect your work. Therefore, combining multiple idle hard disks with disk arrays into one virtual hard disk is a good solution to insufficient disk capacity.

The third advantage is high security. When an error occurs in data storage on the hard disk, the disk array technology can use the existing information to automatically repair the damaged data. The disk array generates a verification code. This verification code is stored on different disks. When a disk is suddenly damaged, the disk array technology can use this verification code to restore data that damages the disk. Therefore, disk array technology is often used on Linux servers to improve server data security.

 Ii. Differences between Linux disk arrays and other operating systems.

From the concept of disk arrays, we know that disk arrays are composed of different hard disks. Other operating systems, such as the Microsoft operating system, must adopt disk arrays. However, Linux is different from other operating systems. It can implement disk arrays in the same hard disk. That is to say, the Linux operating system does not constitute a disk array in the unit of hard disk, but partitions. You can separate a hard disk into different partitions and then combine them into a disk array.

However, if you divide a disk into multiple partitions and combine them into a disk array, you will not be able to enjoy the benefits of the disk array. As mentioned above, improving the efficiency of Hard Disk Data Access and improving data security will not exist. That is to say, it has lost its goal of storing data on different disks to reduce the risk of data corruption and improve data storage efficiency. The use value of the disk array cannot be reflected.

Therefore, the system administrator divides a hard disk into different partitions and implements Disk Arrays for the purpose of experiment and learning. In actual deployment, the author suggests that enterprises still use at least three hard disks to implement disk arrays, so that the disk arrays can truly exert their expected benefits.

  3. How to set a disk array in Linux?

In Linux, the disk array is mainly controlled by the/etc/raidtab configuration file. If the system administrator needs to implement the disk array, the configuration file needs to be created manually. Or copy the file from other places and modify it accordingly. By default, this file is not available in Linux. The following describes the main parameters in this file to help you create a correct disk array configuration file.

Parameter 1: raid-level specifies the disk array type.

Up to now, there are no more than 10 types of disk arrays. However, Linux only supports non-types. The system administrator needs to understand the characteristics of these five disk arrays and select the appropriate disk types based on the actual application scenarios of the enterprise. I usually prefer Linear or RAID-5 disk arrays. For this reason, we will analyze the characteristics of these two types of disks.

The Linear disk array mode is relatively simple. It only serves as the sum of a disk. If this disk array mode is used, the Linux system will first store the data in the first hard disk. The operating system will store data to the second hard disk only when the disk space is used up. And so on. In this mode, because data is not stored in multiple hard disks at the same time in blocks, data access efficiency cannot be improved. At the same time, there is no verification code, so there is no data self-repair function. That is to say, this mode of disk array only plays a role in consolidating a small capacity hard disk and a large hard disk. Therefore, this mode is rarely used. However, because of its simple configuration, it is a good channel for understanding the technology of disk arrays.

The RAID-5 disk array mode is currently the mainstream disk array mode. In this mode, the Linux operating system will cut the data into fixed cell blocks and save them to different hard disks. In addition, this disk array mode generates a verification code and stores the verification code in Different Hard disks. Because it does not retain a Fixed hard disk to store the same verification code, when any hard disk is damaged, damaged data can be repaired. If this mode is used, data storage efficiency can be improved, data security can be enhanced, and different hard disks can be integrated into a virtual hard disk. In addition, it does not store the same-digit verification code in the same hard disk, so it will not cause the overall system performance bottleneck. I use this disk array mode for servers in enterprises.

Parameter 2: chunk-size specifies the chunk size.

After a disk array is used, the data is split into many small blocks and then written to the hard disk. What is the size of this block? In the disk array configuration file, you must specify the size of each write block. The minimum unit is 2 kb. The block size specified by the user must be the integer power of 2. For example, it can be set to 4, 8, or 16. However, this parameter configuration has no practical significance in Liner mode. Because in Liner mode, data is not segmented. Because it first stores data on the first hard disk. When the first hard disk is full, it is stored in the second disk, and so on. Therefore, data is not segmented. Therefore, this parameter does not work for the Liner disk array mode.

Parameter 3: persistent-superblock: sets whether to write data into the super block.

If you deploy a disk array in Microsoft's operating system, you do not need to set this content. However, in Linux, you must set this parameter. Because the Linux system uses Ext2/3 file system. For this file system, hard disk partitions are first divided into blocks. The size of each block on the same ext2 file system is the same. However, for different ext2 file systems, the block size can be different. The typical block size is 1024 bytes or 4096 bytes. This size is determined when the ext2 file system is created. It can be specified by the system administrator, or the file system creation program can automatically select a reasonable value based on the size of the hard disk partition. The block count on a hard disk partition starts from 0, and this count is global for this hard disk partition.

Superblock has a fashionable Chinese name called Superblock. A super block is a part of data starting from byte 1024 (the first byte at the beginning is byte 0. Because the minimum block size is 1024 bytes, the super block may be in block 1 (the block size may be exactly 1024 bytes ), it may also be in block 0 (the block size may exceed 1024 bytes ). The data in the super block is actually the control information of the file volume. It can also be said that it is a volume resource table, and most information about the file volume is saved here. Therefore, the information in this super block is like the partition format in the FAT32 file system, which is very important.

This parameter is used to control whether to write data to the disk. If you want to write data, set it to 1. If you do not want to write data, set it to 0.

 

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.