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 deploy soft Raid under Linux

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the knowledge of "how to deploy soft Raid under Linux". In the operation of actual cases, many people will encounter such a 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!

We all know that Raid means redundant disk (Redundant Arrays of Independent Disks,RAID), which can provide high availability and redundancy according to the needs of the business system. At present, it is common to achieve this function through the server's raid array cards in the market.

Implementation steps

Soft raid is more dependent on the operating system, so its disadvantage is also obvious, it needs to take up system resources (mainly CPU resources). At present, soft raid is common in both Linux and windows. Linux is implemented through mdadm, while in windows, disk management is implemented after win2003.

Experimental environment

Two 50G data disks are mounted on a centos 7.2VM with the hostname host1,host1, and our experiment is completed on these two data disks.

P.S: it needs to be emphasized that the hard drives of two groups of raid in the production environment must be of the same brand, the same model and the same capacity, otherwise it is very easy to cause soft raid failure.

1. Confirm that the mdadm software is installed in the operating system

[root@host1 ~] # rpm-qa | grep mdadmmdadm-3.3.2-7.el7.x86_64

two。 Partition the two data disks and set the partition type to raid

The fdisk command can only partition a hard disk with a capacity of less than 2T, and if it exceeds 2T, you need to use the parted tool. The Parted command will be used later, and I won't repeat it in this section.

The partition type code of raid under fdisk is fd. Under the parted tool, you first need to use mklabel to change the disk format from MBR to GPT, and then you can use the mkpart command to partition. After partitioning, you can use set to set the partition flag to raid.

3. Use the mdadm command to create a raid1

You can see that when you create a Note, there is a hint that soft raid cannot be used as a startup device. This is where soft raid compares chicken ribs.

Mdadm-C / dev/md0-ayes-L1-N2 / dev/xvd [bpenc] 1

Command description:

-C to create an array

-an agrees to create a device. If you do not add this parameter, you must first use the mknod command to create a RAID device, but it is recommended to use the-a yes parameter to create an one-time device.

-l array mode

-n the number of active disks in the array, which plus the number of spare disks should be equal to the total number of disks in the array; / the device name of the dev/md0 array, if there are other array groups, and so on; after creation, you can use cat / proc/mdstat to view the array status

In the following figure, the resync is prompted to complete 95.7% when it is checked for the first time, and the two disks are not synchronized until the second query.

You can also use mdadm-D / dev/md0 to view the status of array groups

4. Create the md0 configuration file echo DEVICE / dev/sd {adepartment b} 1 > / etc/mdadm.confmdadm-Evs > > / etc/mdadm.confmdadm runtime will automatically check the / etc/mdadm.conf file and try to automatically assemble, so you can import the information into / etc/mdadm.conf after configuring raid for the first time.

5. Use / dev/md0 to create a file on / dev/md0, then mount it for use. Mkfs.ext4 / dev/md0

This is the end of "how to deploy soft Raid under Linux". 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: 274

*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

Development

Wechat

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

12
Report