MDADM Command resolution

Source: Internet
Author: User
Tags system log uuid hex code

mdadm Command Resolution

First, in the Linux system is currently the MD (multiple Devices) virtual block device to implement software RAID, the use of multiple low-level block devices to virtual a new virtual device, and the use of striped (stripping) The technology can distribute the data blocks evenly to multiple disks to improve the reading and writing performance of the virtual device, and use different data redundancy algorithm to protect the user's data from being completely lost because of the failure of one block device, and restore the lost data to the new device after the device is replaced.
At present, MD supports LINEAR,MULTIPATH,RAID0 (stripping), RAID1 (mirror), RAID4,RAID5,RAID6,RAID10, and other redundancy levels and levels, It is also possible to support cascading of multiple RAID displays such as the RAID1 0,RAID5 1 type of display,
This article mainly explains how the user layer Mdadm How to manage the software RAID and the problems and solutions that are often encountered in the use. The current system generally has the MD drive module directly compiled into the kernel or compiled into a dynamically loaded driver module, we can after the machine started through the cat/proc/ Mdstat See if the kernel has either loaded the MD driver or cat/proc/devices a MD block device, and can use LSMOD to see if MD can load the module into the system.
[ROOT@TESTGGV ~]# Cat/proc/mdstat
Personalities:
Unused devices:
[ROOT@TESTGGV ~]#
[ROOT@TESTGGV ~]# cat/proc/devices | grep MD
1 RAMDisk
9 MD
254 MDP
[ROOT@TESTGGV ~] #mdadm--version
[ROOT@TESTGGV ~]# Mdadm--version
MDADM-V2.5.4-13 October 2006
[ROOT@TESTGGV ~]#
Second, MDADM management soft RAID display
The MDADM program is a stand-alone program that completes all of the software RAID management functions, with 7 main modes of use:
Create
Create a new array with an idle device, with metadata blocks per Device
Assemble
Assemble each block device that originally belonged to an array as an array
Build
Create or assemble arrays that do not require metadata, with no metadata blocks per Device
Manage
Manage devices that have been stored in the array, such as adding hot spare disks or setting up a disk to fail, and then removing the disk from the array
Misc
Report or modify information about the device in the array, such as querying the array or the device's status information
Grow
Change the capacity used Per device in the array or the number of devices in the array
Monitor
Monitor one or more arrays to escalate the specified event
If the MD driver is compiled into the kernel, when the kernel calls to perform the MD drive, it automatically finds the partition as FD (the Linux RAID autodetect format disk). Therefore, you will typically use the Fdisk tool to partition your HD disk or SD disk, and then set it to an FD disk.
[ROOT@TESTGGV ~]# FDISK/DEV/HDC
The number of cylinders for this disk is set to 25232.
There is no wrong with then, but this is larger than 1024,
And could in certain setups cause problems with:
1 software that runs in boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 1
The cylinder (1-25232, default 1):
Using Default value 1
Last cylinder or size or Sizem or Sizek (1-25232, default 25232):
Using Default Value 25232
Command (M for help): t
Selected partition 1
Hex code (type L to list codes): FD
Changed system type of partition 1 to FD (Linux raid AutoDetect)
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Warning:re-reading the partition table failed with error 16:device or
Busy.
The kernel still uses the old table.
The new table is used at the next reboot.
Syncing disks.
[ROOT@TESTGGV ~]#

If the MD drive is a modular form of loading, the raid display needs to be run by the user layer script when the system is run, as in the Fedoracore system in the/etc/rc.d/ The Rc.sysinit file has instructions to start a soft RAID array, and if the RAID configuration file mdadm.conf exists, call Mdadm to check the options in the configuration file and start the RAID array.
echo "Raidautorun/dev/md0" | Nash--quiet
if [-f/etc/mdadm.conf]; Then
/sbin/mdadm-a-S
Fi-a: Refers to loading an existing display-s: Refers to finding configuration information in a mdadm.conf file.
Manual Stop Disk Chen: #mdadm-S/DEV/MD0

Create a new display
Mdadm uses--create (or its abbreviation-c) parameter to create a new display and to write the identity information of some important arrays as metadata in the specified range of each underlying device
--level (or its abbreviation-L) indicates the raid level of the array
--chunk (or its abbreviation-c) indicates the size of each stripe unit in kilobytes, the default is 64KB, and the size configuration of the stripe unit has a significant impact on the performance of the array under different loads
--raid-devices (or its abbreviation-N) indicates the number of active devices in the array
--spare-devices (or its abbreviation-X) indicates the number of hot spares in the array, and once a disk in the array is invalidated, the MD kernel driver automatically joins the hot spare to the array and then reconstructs the data on the missing disk to the hot spare disk.

To create a RAID 0 device:
Mdadm--create/dev/md0--level=0--chunk=32--raid-devices=3/dev/sdb1/dev/sdc1/dev/sdd1
To create a RAID 1 device:
Mdadm--create/dev/md0--level=1--chunk=128--raid-devices=2--spare-devices=1/dev/sdb1/dev/sdc1/dev/sdd1
To create a RAID5 device:
Mdadm--create/dev/md0--level=5--raid-devices=5/dev/sd[c-g]1--spare-devices=1/dev/sdb1
To create a RAID 10 device:
Mdadm-c/dev/md0-l10-n6/dev/sd[b-g]-x1/dev/sdh
Create a RAID1 0 device:
Mdadm-c/DEV/MD0-L1-N2/DEV/SDB/DEV/SDC
Mdadm-c/DEV/MD1-L1-N2/DEV/SDD/DEV/SDE
Mdadm-c/DEV/MD2-L1-N2/DEV/SDF/DEV/SDG
Mdadm-c/DEV/MD3-L0-N3/DEV/MD0/DEV/MD1/DEV/MD2

The length of initialization is related to the performance of the disk array itself and the application load of read and write, using Cat/proc/mdstat information to query the speed of the current refactoring of the RAID array and the expected completion time.
Cat/proc/mdstat
[Root@fc5 mdadm-2.6.3]# Cat/proc/mdstat
Personalities: [RAID10]
Md0:active RAID10 Sdh[6] (S) sdg[5] sdf[4] sde[3] sdd[2] sdc[1] sdb[0]
3145536 blocks 64K chunks 2 near-copies [6/6] [uuuuuu]
[===>...] Resync = 15.3% (483072/3145536) finish=0.3min speed=120768k/sec
Unused devices:
[Root@fc5 mdadm-2.6.3]# Cat/proc/mdstat
Personalities: [RAID10]
Md0:active RAID10 Sdh[6] (S) sdg[5] sdf[4] sde[3] sdd[2] sdc[1] sdb[0]
3145536 blocks 64K chunks 2 near-copies [6/6] [uuuuuu]
Unused devices:
Use exhibitions:
The MD device can be read-write directly as a common block device, or it can be formatted as a file system.
#mke2fs-j/dev/md0
Mkdir-p/mnt/md-test
#mount/dev/md0/mnt/md-test
To stop a running display:
When the array does not have a file system or other storage applications and advanced devices to use, you can use--stop (or its abbreviation-s) to stop the array; If the command returns a device or resource-busy type of error, it means that/dev/md0 is being used by the upper level and cannot be stopped for the time being. , which will also ensure consistency of data on the array.
[Root@fc5 mdadm-2.6.3]#./mdadm--stop/dev/md0
Mdadm:fail to stop Array/dev/md0:device or resource busy
[Root@fc5 mdadm-2.6.3]# umount/dev/md0
[Root@fc5 Mdadm-2.6.3]#./mdadm--stop/dev/md0
Mdadm:stopped/dev/md02.3 Assembling an array that had been createdThe pattern--assemble or its abbreviation (-a) is primarily to check the metadata information of the underlying device and then assemble it into an active array. If we already know that the array consists of those devices, you can specify which devices to use to start the array. [Root@fc5 mdadm-2.6.3]#./mdadm-a/dev/md0/dev/sd[b-h]
Mdadm:/dev/md0 has been started with 6 drives and 1 spare. If you have a profile (/etc/mdadm.conf), you can use the command mdadm-as/dev/md0. Mdadm first checks the device information in the mdadm.conf, then reads the metadata information from each device and checks to see if the array information is consistent, and if the information is consistent, start the pattern. If you do not configure the/etc/mdadm.conf file and you do not know that the array consists of those disks, you can use the command--examine (or its abbreviation-e) to detect the presence of array metadata information on the current block device. [Root@fc5 mdadm-2.6.3]#./mdadm-e/DEV/SDI
Mdadm:no MD superblock detected ON/DEV/SDI.
[Root@fc5 mdadm-2.6.3]#./mdadm-e/dev/sdb
/DEV/SDB:
Magic:a92b4efc
version:00.90.00
uuid:0cabc5e5:842d4baa:e3f6261b:a17a477a
Creation Time:sun Aug 22 17:49:53 1999
Raid LEVEL:RAID10
Used Dev size:1048512 (1024.11 MiB 1073.68 MB)
Array size:3145536 (3.00 GiB 3.22 GB)
Raid Devices:6
Total Devices:7
Preferred minor:0
Update Time:sun Aug 22 18:05:56 1999
State:clean
Active Devices:6
Working devices:7
Failed devices:0
Spare devices:1
Checksum:2f056516-correct
events:0.4
layout:near=2, Far=1
Chunk size:64k
Number Major Minor Raiddevice state
This 0 8 0 active Sync/dev/sdb
0 0 8 0 Active Sync/dev/sdb
1 1 8 1 active SYNC/DEV/SDC
2 2 8 2 active SYNC/DEV/SDD
3 3 8 3 active SYNC/DEV/SDE
4 4 8 4 Active SYNC/DEV/SDF
5 5 8 5 Active SYNC/DEV/SDG
6 6 8 112 6 SPARE/DEV/SDH
From the above command, you can find the unique identifier of the array UUID and the device name that the array contains, and then use the commands above to assemble the array, or you can assemble the array using the UUID identity. Information devices that do not have consistent metadata (such as/DEV/SDA and/DEV/SDA1) Mdadm programs are automatically skipped.

[Root@fc5 mdadm-2.6.3]#./mdadm-av--uuid=0cabc5e5:842d4baa:e3f6261b:a17a477a
/dev/md0/dev/sd*
Mdadm:looking for Devices for/dev/md0
Mdadm:no recogniseable superblock ON/DEV/SDA
Mdadm:/DEV/SDA has wrong uuid.
Mdadm:no recogniseable superblock on/dev/sda1
Mdadm:/DEV/SDA1 has wrong uuid.
Mdadm:no RAID superblock ON/DEV/SDI
Mdadm:/DEV/SDI has wrong uuid.
Mdadm:/dev/sdi1 has wrong uuid.
Mdadm:no RAID superblock ON/DEV/SDJ
Mdadm:/DEV/SDJ has wrong uuid.
Mdadm:/dev/sdj1 has wrong uuid.
Mdadm:no RAID superblock ON/DEV/SDK
Mdadm:/DEV/SDK has wrong uuid.
Mdadm:/dev/sdk1 has wrong uuid.
Mdadm:/dev/sdb is identified as a-of/dev/md0, slot 0.
Mdadm:/DEV/SDC is identified as a-of/dev/md0, slot 1.
Mdadm:/DEV/SDD is identified as a-of/dev/md0, slot 2.
Mdadm:/DEV/SDE is identified as a-of/dev/md0, slot 3.
Mdadm:/DEV/SDF is identified as a-of/dev/md0, slot 4.
Mdadm:/DEV/SDG is identified as a-of/dev/md0, slot 5.
Mdadm:/DEV/SDH is identified as a-of/dev/md0, slot 6.
MDADM:ADDED/DEV/SDC to/dev/md0 as 1
MDADM:ADDED/DEV/SDD to/dev/md0 as 2
Mdadm:added/dev/sde to/dev/md0 as 3
MDADM:ADDED/DEV/SDF to/dev/md0 as 4
MDADM:ADDED/DEV/SDG to/dev/md0 as 5
MDADM:ADDED/DEV/SDH To/dev/md0 as 6
Mdadm:added/dev/sdb to/dev/md0 as 0
Mdadm:/dev/md0 has been started with 6 drives and 1 spare.
configuration file:
/etc/mdadm.conf as the default profile, the primary role is to easily track the configuration of soft raid, especially to configure monitoring and event escalation options. The assemble command can also use--config (or its abbreviation-c) to specify a configuration file. We can usually build the # standing configuration file with the following command
#echo device/dev/sdc1/dev/sdb1/dev/sdd1 >/etc/mdadm.conf
#mdadm--detail--scan >>/etc/mdadm.conf

When you start the array using a configuration file, Mdadm queries the device and array contents in the configuration file, and then starts running all of the raid arrays that run. If the device name of the array is specified, only the corresponding array is started.
[Root@fc5 mdadm-2.6.3]#./mdadm-as
Mdadm:/dev/md1 has been started with 3 drives.
Mdadm:/dev/md0 has been started with 6 drives and 1 spare.
[Root@fc5 mdadm-2.6.3]# Cat/proc/mdstat
Personalities: [RAID0] [RAID10]
Md0:active RAID10 sdb[0] sdh[6] (S) sdg[5] sdf[4] sde[3] sdd[2] sdc[1]
3145536 blocks 64K chunks 2 near-copies [6/6] [uuuuuu]
Md1:active RAID0 sdi1[0] sdk1[2] sdj1[1]
7337664 Blocks 32k Chunks
Unused devices:
[Root@fc5 mdadm-2.6.3]#./mdadm-s/dev/md0/dev/md1
Mdadm:stopped/dev/md0
Mdadm:stopped/dev/md1
[Root@fc5 mdadm-2.6.3]#./mdadm-as/dev/md0
Mdadm:/dev/md0 has been started with 6 drives and 1 spare.
[Root@fc5 mdadm-2.6.3]# Cat/proc/mdstat
Personalities: [RAID0] [RAID10]
Md0:active RAID10 sdb[0] sdh[6] (S) sdg[5] sdf[4] sde[3] sdd[2] sdc[1]
3145536 blocks 64K chunks 2 near-copies [6/6] [uuuuuu]
Unused devices:
2.4 Querying the status of the array
We can view the status of all running RAID arrays by Cat/proc/mdstat information, first in the first row is the MD device name, the active and inactive options indicate whether the array can read and write, then the raid level of the array, followed by the array of block devices, square brackets The number in [] indicates the serial number of the device in the array, (S) indicates that it is a hot spare, (F) indicates that the disk is a faulty state. First in the second row is the size of the array, the unit is KB, then the size of the chunk-size, then the layout type, and the layout types at different RAID levels, [6/6] and [uuuuuu] indicate that the array has 6 disks and 6 disks are functioning, and [5/ 6] and [_UUUUU] indicate that 5 of the 6 disks on the array are running correctly, and that the disk in the position where the underscore corresponds is faulty.
[Root@fc5 mdadm-2.6.3]# Cat/proc/mdstat
Personalities: [RAID6] [RAID5] [RAID4] [RAID1]
Md0:active RAID5 sdh[6] (S) sdg[5] sdf[4] sde[3] sdd[2] sdc[1] sdb[0]
5242560 blocks level 5, 64k chunk, Algorithm 2 [6/6] [uuuuuu]
Unused devices:
[Root@fc5 mdadm-2.6.3]#./mdadm/dev/md0-f/dev/sdh/dev/sdb
MDADM:SET/DEV/SDH Faulty in/dev/md0
Mdadm:set/dev/sdb Faulty in/dev/md0
[Root@fc5 mdadm-2.6.3]# Cat/proc/mdstat
Personalities: [RAID6] [RAID5] [RAID4] [RAID1]
Md0:active RAID5 sdh[6] (f) sdg[5] sdf[4] sde[3] sdd[2] sdc[1] sdb[7] (f)
5242560 blocks level 5, 64k chunk, Algorithm 2 [6/5] [_uuuuu]
Unused devices:
We can also use the Mdadm command to view brief information about the specified array (using--query or its initials-Q) and details (using--detail or its abbreviated-D) details including RAID version, time created, RAID level, array capacity, free space, number of devices, Super block status, update time, UUID information, status of each device, RAID algorithm level type and layout, and block size information. Device status information is divided into active, sync, spare, faulty, rebuilding, removing, and so on.
Root@fc5 mdadm-2.6.3]#./mdadm--query/dev/md0
/dev/md0:2.100gib RAID10 6 devices, 1 spare. Use the Mdadm--detail for the more detail.
[Root@fc5 mdadm-2.6.3]#./mdadm--detail/dev/md0
/DEV/MD0:
version:00.90.03
Creation Time:sun Aug 22 17:49:53 1999
Raid LEVEL:RAID10
Array size:3145536 (3.00 GiB 3.22 GB)
Used Dev size:1048512 (1024.11 MiB 1073.68 MB)
Raid Devices:6
Total Devices:7
Preferred minor:0
Persistence:superblock is persistent
Update Time:sun Aug 22 21:55:02 1999
State:clean
Active Devices:6
Working devices:7
Failed devices:0
Spare devices:1
layout:near=2, Far=1
Chunk size:64k
uuid:0cabc5e5:842d4baa:e3f6261b:a17a477a
events:0.122
Number Major Minor Raiddevice state
0 8 0 Active Sync/dev/sdb
1 8 1 Active SYNC/DEV/SDC
2 8 2 Active SYNC/DEV/SDD
3 8 3 Active SYNC/DEV/SDE
4 8 4 Active SYNC/DEV/SDF
5 8 5 Active SYNC/DEV/SDG
6 8 112-SPARE/DEV/SDH

Manage Arrays
Mdadm can add and remove disks from the running array in manage mode. Often used to identify failed disks, increase spare (hot spare) disks, and remove defunct disks from the array, and so on. Use--fail (or its abbreviation-f) To specify disk corruption.
[Root@fc5 mdadm-2.6.3]#./mdadm/dev/md0--fail/dev/sdb
Mdadm:set/dev/sdb Faulty in/dev/md0
The disk is removed from the disk array using the--remove (or its abbreviated--F) parameter when the disk is corrupted, but cannot be removed from the array if the device is also being used by the array. [Root@fc5 mdadm-2.6.3]#./mdadm/dev/md0--remove/dev/sdb
Mdadm:hot Removed/dev/sdb
[Root@fc5 mdadm-2.6.3]#./mdadm/dev/md0--remove/dev/sde
Mdadm:hot Remove failed For/dev/sde:device or resource busy
If the array has a spare disk, the data on the damaged disk is automatically refactored onto the new spare disk;
[Root@fc5 mdadm-2.6.3]#./mdadm-f/dev/md0/dev/sdb; Cat/proc/mdstat
Mdadm:set/dev/sdb Faulty in/dev/md0
Personalities: [RAID0] [RAID10]
Md0:active RAID10 sdh[6] sdb[7] (F) sdc[0] sdg[5] sdf[4] sde[3] sdd[2]
3145536 blocks 64K chunks 2 near-copies [6/5] [u_uuuu]
[=======> ...] Recovery = 35.6% (373888/1048512) finish=0.1min speed=93472k/sec
Unused devices:
If the array does not have a hot spare disk, you can use the--add (or its abbreviation-a) parameter to increase the hot spare disk
[Root@fc5 mdadm-2.6.3]#./mdadm/dev/md0--ADD/DEV/SDH
Mdadm:added/dev/sdh
Monitoring Array
The RAID array can be monitored using mdadm, and the monitoring program periodically queries the specified event for occurrence, and is then properly handled according to the configuration. For example, when there is a problem with the disk device in the array, you can send the message to the administrator, or when there is a problem with the disk by the callback program for automatic disk replacement, all monitoring events can be logged to the system log. The events currently supported by Mdadm are rebuildstarted, Rebuildnn (NN is,,, or), rebuildfinished, Fail,failspare,spareactive,newarray, Degradedarray, Movespare, sparesmissing, TestMessage.
If the MDADM monitoring process is configured to query the MD device once every 300 seconds, when an array error occurs, it sends a message to the specified user, executes the event-handling program, and logs the escalated event to the system's log file. Use the--daemonise parameter (or its abbreviation-f) to keep the program running in the background. If you want to send a message requires SendMail program to run, when the e-mail address is configured as an extranet address should first test whether it can be sent out.
[Root@fc5 mdadm-2.6.3]#./mdadm--monitor--mail=root@localhost--program=/root/md.sh
--syslog--delay=300/dev/md0--daemonise

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.