Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Software disk Array RAID in linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "linux how to use software disk array RAID", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "linux how to use software disk array RAID" this article.

The English full name of disk array is Redundant Arrays of Inexpensive Disks (RAID), that is, fault-tolerant cheap disk array. Several smaller disks can be consolidated into a larger disk device through some technologies; and this device is not just a storage function, it also has a data protection function.

Level of RAID:

× RAID-0 (equivalent mode, stripe): better performance

This mode is made up of disks of the same model and capacity, and there can be multiple disks. RAID will divide each disk into equal blocks (usually 4K ~ 2K, etc.). Then when a file is written, the file will be cut according to the block size, and then placed on each disk in order. Because each disk staggers to store data, so when your data is to be written to RAID The data will be placed on each disk in the same amount. The more disks make up the RAID-0, the better the performance will be.

Cons: a disk hang point, the entire file system crashes, can not be recovered. And all disks must have the same capacity, otherwise performance will degrade.

× RAID-1 (Image Mode, mirror): full backup

This mode should also be the same model, the same capacity of the disk, preferably exactly the same, carved out of the same mold.

The data transferred to the Icano bus is copied to each disk, so the performance of the write becomes very poor, but if you use the hardware RAID (disk array card), the disk array card will actively copy it for you, and you don't need the Icano bus. But the disk array card is very expensive, I can't afford it, so it's tragic. The biggest use of RAID-1 is for backup, but it has good read performance.

× RAID 0mm 1, RAID 1x 0

The performance of RAID-0 is better but the data is not secure, while the data of RAID-1 is secure but the performance is not good, can you combine it?

RAID 0room1: first let N disks make up RAID-0, and then let the other N disks also form RAID-0, so I get two sets of RAID-0, and then put these two sets of RAID-0 into a set of RAID-1.

RAID 1: first, 2N disks are grouped into N groups, with two disks in each group, and two disks in each group are composed of RAID-1, and then the N groups of RAID-1 are composed of RAID-0.

Disadvantages: half the capacity of the disk is used for backup, what a tragedy!

RAID-5: balanced consideration of performance and data backup

RAID-5 requires at least three or more disks to form this type of disk array. The data writing of this disk array is a bit like RAID-0, except that during each circular write, a parity check data (Parity) is added to each disk, which records the backup data of other disks for rescue in the event of disk corruption.

The capacity of RAID-5 needs to be reduced by one disk capacity, that is, the total number of disks in the array, because a disk capacity is required to hold the parity check data Parity.

The read performance of RAID-5 is very good, which is comparable to that of RAID-0, but the write performance is very awkward, and CPU has to spend time calculating parity check data when it comes to software disk arrays. At the same time, it can only ensure the security of data damaged by one disk, and hang up if two disks are damaged.

RAID-6: similar to RAID-5, but this time two disks will be used as Parity storage. It can support two disks to be damaged at the same time. This probability should be lower than the probability of being hit by a donkey car while walking on the road. ^ _ ^

= Spare Disk: the function of preparing disk =

In order to enable the system to actively rebuild when the disk is broken in real time, you need to prepare the assistance of disk spare disk, which is not usually included in the disk array. When any disk in the disk array is damaged, spare disk will be actively pulled into the disk array, and the broken disk will be removed from the disk array, and then immediately rebuild the data system. It will be even better if your disk array also supports hot-swappable. Because at this time, you only need to unplug the bad disk, replace it with a new one, and then set the new disk to spare disk, and you can do everything without shutting down and restarting. This is very helpful to the stability of the server.

Advantages of disk arrays:

× data security and reliability, which means that the data can be recovered if the hard disk is broken.

× read and write performance, RAID-0 can enhance the read and write performance, so that your department, oh, Imax O system part can be improved.

X capacity: multiple disks can be combined, so a single file system can have considerable capacity.

The software disk array provided by centos is listed as mdadm software, which is based on partitions or disks, which means you don't need multiple disks to design your disk array. In addition, mdadm supports the RAID-0,RAID-1,RAID-5 level just mentioned, as well as the functionality of spare disk. And the management mechanism can also achieve similar hot-swappable functions, can be online (normal use of the file system) for partition swap, the use is very convenient.

Note: the hard disk array looks like a large disk in linux, and all devices are filenamed / dev/sd [Amurp] because of the use of SCSI modules. Because the software disk array is a system simulation, the device file name used is the device file of the system, the file name is / dev/md0, / dev/md1.

Settings for the software disk array

# mdadm-detail / dev/md0

# mdadm-create-auto=yes / dev/md [0-9]-raid-device=4-level= [015]-spare-device=2 / dev/sd5 / dev/sd6

-create: parameter for the new RAID

-auto=yes: decide to create a new software disk array device, namely / dev/md0, / dev/md1, etc.

-raid-devices=N: a device that uses N disks as disk arrays

-spare-devices=N: use N disks as backup spare devices

-level= [015]: sets the level of the disk array. There is a lot of support, but it is recommended that you only use 0pl 1pm 5.

-detail: details of the disk array device that follows

Note that the last device file name can be a whole disk, such as / dev/sdb, or a partition, such as / dev/sdb1, but the total number of these device file names must be equal to the sum of-raid-devices and-spare-devices.

Next I will try to build a RAID-5 software disk array, it seems that this is more commonly used, very suitable.

I want this RAID-5 environment to look like this:

× 4 partitions are used to form RAID-5

Each partition is about 1G in size, and it is better to make sure that each partition is the same size.

* add another partition set to sparedisk

The size of this sparedisk is the same as that of other RAID partitions.

* Mount this RAID-5 device to the / mnt/raid directory

First, use fdisk to build 5 1G partitions:

# fdisk / dev/sda

The preceding ellipsis.

Command (m for help): n

Every time the 1000m space size, note, I do not know the reason for the horse, first sector to manually enter, with the p option to view, with the last partition sector number + 2049 is the first idle sector number, this may be a fedora of a bug, partition is not continuous, regardless of the, go to try. Embarrassed

When the last partition is viewed with p, it looks like this:

Device Boot Start End Blocks Id System

/ dev/sda1 2048 206847 102400 7 HPFS/NTFS/exFAT

/ dev/sda2 * 206848 169859071 84826112 7 HPFS/NTFS/exFAT

/ dev/sda3 169859072 462827821 146484375 7 HPFS/NTFS/exFAT

/ dev/sda4 462829568 976773119 256971776 5 Extended

/ dev/sda5 462833664 463243263 204800 83 Linux

/ dev/sda6 463245312 631181311 83968000 83 Linux

/ dev/sda7 631183360 799119359 83968000 83 Linux

/ dev/sda8 799121408 803315711 2097152 82 Linux swap / Solaris

/ dev/sda9 803317760 805365759 1024000 83 Linux

/ dev/sda10 805367808 807415807 1024000 83 Linux

/ dev/sda11 807417856 809465855 1024000 83 Linux

/ dev/sda12 809467904 811515903 1024000 83 Linux

/ dev/sda13 811517952 813565951 1024000 83 Linux

The following from 9 to 13 are the five partitions I have just divided, each about 1G, all of the same size.

# partprobe

Then it's easy to create a disk array through mdadm. Oh, yeah.

# mdadm-create-auto=yes / dev/md0-level=5-raid-devices=4-spare-devices=1 / dev/sda {9pm 10L 11L 12L 13}

Check it out (wait a minute, go for a cup of coffee first, because if you run it right away, the following message about building data may appear):

The code is as follows:

# mdadm-- detail / dev/md0

/ dev/md0:

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report