In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to build a soft raid experiment with 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!
I. definition of Raid
RAID, full name Redundant Array ofInexpensive Disks, Chinese name for cheap disk redundant array. RAID can be divided into soft RAID and hard RAID. Soft RAID realizes multiple hard disk redundancy through software. On the other hand, hard RAID is generally realized by raid card to RAID. The former is simple in configuration and flexible in management. It is the best choice for small and medium-sized enterprises. Hard RAID tends to be expensive. However, there are some advantages in performance.
RAID classification
RAID can be divided into the following categories, make a table to understand:
RAID 0: the fastest access speed without fault tolerance
RAID 1: the cost of full fault tolerance is high and the utilization of hard disk is low.
RAID 3: write performance preferably without multitasking
RAID 5: with multitasking and fault tolerance, there is overhead when writing
RAID 0room1: high speed and high cost of full fault tolerance
2. Detailed explanation of Linux RAID 5 experiment
(note: if you are prompted with insufficient permissions in the following linux command, please add sudo before the command)
1. Add 4 hard drives
Four hard drives can be set up with a virtual machine. Add a hard disk to the virtual machine, always using the default setting.
After it is added, linux restart can recognize the
You can use the fdisk-l command to see
The four hard drives added are
/ dev/sdb
/ dev/sdc
/ dev/sdd
/ dev/sde .
2. Zoning
For example, partition / dev/sdb
Fdisk / dev/sdb
Device contains neither a valid DOS partition table, norSun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memoryonly
Until you decide to write them. After that, of course, theprevious
Content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will becorrected by w (rite)
Command (m for help): n # create a new partition by n
Command action
E extended
P primary partition (1-4) # enter p to choose to create a primary partition
P
Partition number (1-4): 1 # enter 1 to create the first primary partition
First cylinder (1-130, default 1): # enter directly, select the partition to start the cylinder, and here we start at 1.
Using default value 1
Last cylinder or + size or + sizeM or + sizeK (1-102, default 130):
Using default value 130
Command (m for help): W # and then enter w write disk
The partition table has been altered!
Calling ioctl () to re-readpartition table.
Syncing disks.
The other divisions do the same. All of them are divided into one area. The following command displays all partition information:
Fdisk-l
You will see / dev/sdb1 / dev/sdc1 / dev/sdd1 / dev/sde1
3. Create RAID
Install mdadm softwar
Sudo apt install mdadm
Mdadm-create / dev/md0-level=5-n3 / dev/sdb1 / dev/sdc1 / dev/sdd1
# means to create a RAID device named md0, with a level of RAID 5, using three disks, namely / dev/sdb1 / dev/sdc1 / dev/sdd1
Mdadm: array / dev/md0 started.
OK, we have initially established RAID. Let's take a look at the specific situation.
Mdadm-detail / dev/md0
4 the startup method of RAID (this step can be skipped during the experiment)
There are two ways to start RAID, one is to start RAID by specifying RAID devices and RAID members, and the other is to start RAID by loading RAID's default configuration file.
The first method:
Syntax:
Mdadm-A RAID device RAID member
Note:
-An is the same as-- assemble, which means to activate an existing RAID
RAID device, which is / dev/md0 or / dev/md1. Based on the RAID device you created
RAID members, that is, the RAID you want to start, and which of its subordinate devices should be listed one by one, separated by spaces in the middle.
For example:
For example, I'm going to start the RAID I just established, the device is / dev/md0, and the members under it are / dev/sdb1 and / dev/sdc1 and / dev/sde1;, so I'm going to use the following method
Mdadm-A / dev/md0 / dev/sdb1 / dev/sdc1 / dev/sde1
The second method:
In order for RAID to boot, you need to edit the RIAD configuration file. The default name is mdadm.conf, this file does not exist by default, you have to create it yourself. The main function of the configuration file is that the soft RAID can be loaded automatically when the system is started, and it is also convenient for future management.
Mdadm-- detail-- scan > / etc/mdadm.conf
[root@localhost ~] # cat / etc/mdadm.conf
ARRAY / dev/md0 level=raid5 num-devices=3 UUID=e62a8ca6:2033f8a1:f333e527:78b0278a
Devices=/dev/sdb1,/dev/sdc1,/dev/sdd1
# the default format is incorrect and needs to be modified in the following ways:
Vi / etc/mdadm.conf
Cat / etc/mdadm.conf
Devices / dev/sda1,/dev/sdb1,/dev/sdc1,/dev/sdd1
ARRAY / dev/md0 level=raid5 num-devices=3 UUID=e62a8ca6:2033f8a1:f333e527:78b0278a
5. Create a file system with / dev/md0
Mkfs-t ext4 / dev/md0
6. Mount / dev/md0 to the system, and we will test whether it is available:
Mkdir / mdadm
Mount / dev/md0 / mdadm/
Cd / mdadm/
Ls
Cd / etc/services.
Ls
7. What if I want to remove a broken hard drive or add a hard drive?
# Delete a hard disk
Mdadm / dev/md0-f/dev/sdc1
Mdadm / dev/md0--remove / dev/sdc1
Mdadm: hot removed / dev/sdc1
Cat / proc/mdstat
Personalities: [raid5]
Md0: active raid5 sdd1 [2] sdb1 [1] sda1 [0]
2088192 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
Unused devices:
# add a hard drive
Mdadm / dev/md0-- add / dev/sdc1
Mdadm: hot added / dev/sdc1
Cat / proc/mdstat
Personalities: [raid5]
Md0: active raid5 sdc1 [3] sdd1 [2] sdb1 [1] sda1 [0]
2088192 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
Unused devices:
This is the end of the content of "how to build a soft raid experiment with 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: 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.