Simulation disk array (RAID) in Red Hat Linux 7)

Source: Internet
Author: User
Tags hex code

Simulation disk array (RAID) in Red Hat Linux 7)

I. Introduction to disk arrays

A disk array (RAID) is a Redundant Array composed of Independent Disks.

A disk array is a combination of many Inexpensive Disks into a disk group with a large capacity. The addition effect produced by the data provided by individual disks improves the efficiency of the entire disk system. This technology is used to cut data into multiple segments and store them on each hard disk.
The disk array can also use the concept of Parity Check to read data when any hard disk in the array fails, after calculation, the data is re-inserted into the new hard disk.
 
Ii. Disk Array Mode

There are three types of Disk Arrays: External disk array, internal disk array, and software simulation.

Step 3: Perform disk array Simulation
1: RedHat7.0
First, use cat/proc/partitions to view available disks in the system.

[Root @ localhost ~] # Cat/proc/partitions
Major minor # blocks name

253 0 10485760 vda
253 1 10484142 vda1
253 16 10485760 vdb
7 0 3655680 loop0
 
The vdb disk is not used, so we will use it to achieve our goal.
Next we will divide the required partitions:

Run the fdisk dev/vdb command.

Enter m for help.
Selecting n indicates that a partition is required.

In the next partition mode, select primary partition p, which is the default partition.

Select Partition number (1-4, default 1): this random
 
Next, determine First sector (2048-20971519, default 2048): it is best to select the default value to make full use of the space.

Next, select the partition size:

Then you can use p to check whether the partition is successful.

Blue is used in the following important areas:

[Root @ localhost ~] # Fdisk/dev/vdb
Welcome to fdisk (util-linux 2.23.2 ).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xe42a4683.

Command (m for help): n
Partition type:
P primary (0 primary, 0 extended, 4 free)
E extended
Select (default p ):
Using default response p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048 ):
Using default value 2048
Last sector, + sectors or + size {K, M, G} (2048-20971519, default 20971519): + 2G
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk/dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dosDisk identifier: 0xe42a4683

Device Boot Start End Blocks Id System
/Dev/vdb1 2048 4196351 2097152 83 Linux

Command (m for help ):

 
And so on, we first divide three new partitions.

Device Boot Start End Blocks Id System
/Dev/vdb1 2048 4196351 2097152 83 Linux
/Dev/vdb2 4196352 8390655 2097152 83 Linux
/Dev/vdb3 8390656 12584959 2097152 83 Linux

 
Next, we need to change the created Partition Function label to raid.
First input I in Command (m for help): l

Find fd Linux raid auto in the last row
Then we found the command corresponding to the raid format.

Enter m
Command (m for help): m

Command (m for help): m
Command action
A toggle a bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag
D delete a partition
G create a new empty GPT partition table
G create an IRIX (SGI) partition table
L list known partition types
M print this menu
N add a new partition
O create a new empty DOS partition table
P print the partition table
Q quit without saving changes
S create a new empty Sun disklabel
T change a partition's system id
U change display/entry units
V verify the partition table
W write table to disk and exit
X extra functionality (experts only)
Then we found that t is what we need
Similarly, change the three partition formats to Linux raid autodetect.

Click (here) to fold or open

Command (m for help): t
Partition number (1-3, default 3): 1
Hex code (type L to list all codes): fd
Changed type of partition 'linux 'to 'linux raid autodetect'

Command (m for help): p

Disk/dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk label type: dos
Disk identifier: 0xe42a4683

Device Boot Start End Blocks Id System
/Dev/vdb1 2048 4196351 2097152 fd Linux raid autodetect
/Dev/vdb2 4196352 8390655 2097152 83 Linux
/Dev/vdb3 8390656 12584959 2097152 83 Linux

Command (m for help ):
Then, use wq to exit and save.
Check whether the partition is successful in cat/proc/partitions.

[Root @ localhost ~] # Cat/proc/partitions
Major minor # blocks name

253 0 10485760 vda
253 1 10484142 vda1
253 16 10485760 vdb
253 17 2097152 vdb1
253 18 2097152 vdb2
253 19 2097152 vdb3
7 0 3655680 loop0
Then you should enter the topic.
Run the following command:
Mdadm-C/dev/md0-a yes-l 1-n 2-x 1/dev/vdb {1 .. 3}
-C Creation
-File a does not exist.
-L raid level
-N number of devices
-X number of idle Devices
This command is used to create the/dev/md0 device as the raid internal card function. The vdb1 vdb2 device is associated with the idle device vdb3 for later suffering.

Use cat/proc/mdstat to view device information

[Root @ localhost ~] # Cat/proc/mdstat

Personalities: [raid1]
Md0: active raid1 vdb3 [2] (S) vdb2 [1] vdb1 [0]
2096064 blocks super 1.2 [2/2] [UU]
[============>...] Resync = 56.3% (1181056/2096064) finish = 0.2 min speed = 56240 K/sec

Unused devices: <none>
Because you want to use it, you need to format a file system.

Click (here) to fold or open

[Root @ localhost ~] # Mkfs. xfs/dev/md0
Meta-data =/dev/md0 isize = 256 agcount = 4, agsize = 131004 blks
= Sectsz= 512 attr = 2, projid32bit = 1
= Crc = 0
Data = bsize = 4096 blocks = 524016, imaxpct = 25
= Sunit = 0 swidth = 0 blks
Naming = version 2 bsize = 4096 ascii-ci = 0 ftype = 0
Log = internal log bsize = 4096 blocks = 2560, version = 2
= Sectsz= 512 sunit = 0 blks, lazy-count = 1
Realtime = none extsz = 4096 blocks = 0, rtextents = 0
Mount it to/mnt mount/dev/md0/mnt (temporary mounting)
To permanently Mount vim/etc/fstab
/Dev/md0/mnt xfs defaults 0 0

[Root @ localhost ~] # Mount/dev/md0/mnt
[Root @ localhost ~] # Df
Filesystem 1K-blocks Used Available Use % Mounted on
/Dev/vda1 10473900 7009908 3463992 67%/
Devtmpfs 927072 0 927072 0%/dev
Tmpfs 942660 92 942568 1%/dev/shm
Tmpfs 942660 17064 925596 2%/run
Tmpfs 942660 0 942660 0%/sys/fs/cgroup
/Dev/loop0 3654720 3654720 0 100%/var/www/html/pub
/Dev/md0 2085824 32928 2052896 2%/mnt
This is done, but many people do not think it is successful if they do not see the phenomenon. Then we will delete the partition It is using, such as vdb1.
Run the mdadm/dev/mad0-f/dev/vdb1 command.
Run cat/proc/mdstat to view the device status.
The damaged partition data will be put in the idle vdb3
If we don't know the device information, we don't even know it. Because it is quietly executed in the background, it doesn't affect our work. We only need to check regularly and change the bad information.
We can also restore damaged partitions.
Mdadm/dev/md0-a/dev/vdb1 restore the device

[Root @ localhost dev] # cat/proc/mdstat
Personalities: [raid1]
Md0: active raid1 vdb3 [2] vdb2 [1] vdb1 [0] (F)
2096064 blocks super 1.2 [2/1] [_ U]
[============> ......] Recovery = 52.6% (1104448/2096064) finish = 0.6 min speed = 25945 K/sec

Unused devices:
You can also execute the following command
Mdadm/dev/md0-r/dev/vdb1 remove a device
Mdadm-S/dev/md0 stop the device

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.