In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Today, what the editor shares with you is what the function of the mdadm command is. I believe many people do not know much about it. In order to let you know more about the mdadm command, I have summarized the following contents. Let's take a look at the following. I'm sure you'll get something.
Detailed explanation of mdadm command
Detailed explanation of mdadm command and experimental process
one。 Concept
Mdadm is the abbreviation of multiple devices admin, it is a standard software RAID management tool under Linux, the author is Neil Brown
two。 Characteristics
Mdadm can diagnose, monitor, and collect detailed array information
Mdadm is a separate integrated program rather than a collection of distributed programs, so there is a common syntax for different RAID management commands
Mdadm can perform almost all functions without the need for a configuration file (and there is no default profile)
three。 Function (reference)
At present, software RAID is implemented as MD (Multiple Devices) virtual block device in linux system, a new virtual device is virtualized by using multiple underlying block devices, and data blocks are evenly distributed to multiple disks by stripping technology to improve the read and write performance of virtual devices, and different data redundancy algorithms are used to protect user data from being completely lost due to the failure of a block device. It can also restore the lost data to the new device after the device has been replaced.
At present, MD supports different levels and levels of redundancy such as linear,multipath,raid0 (stripping), raid1 (mirror) and raid4,raid5,raid6,raid10. Of course, it can also support the cascading of multiple RAID displays to form raid10, raid5 1 and other types of displays.
four。 Experiment
Test question: create 4 1G disks, and create 3 as raid5 array disks and 1 as hot backup disk. Test hot backup disks to replace disks in the array and synchronize data. Remove the damaged disk and add a new disk as a hot backup disk. Finally, it is required to boot and mount automatically.
4.1 create disk
[root@xiao ~] # fdisk / dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): nFirst cylinder (10486-13054, default 10486): Using default value 10486Last cylinder, + cylinders or + size {K default G} (10486-13054, default 13054): + 1GCommand (m for help): nFirst cylinder (10618-13054, default 10618): Using default value 10618Last cylinder, + cylinders or + size {K cent G} (10618-13054 Default 13054): + 1GCommand (m for help): nFirst cylinder (10750-13054, default 10750): Using default value 10750Last cylinder, + cylinders or + size {KMagazine G} (10750-13054, default 13054): + 1GCommand (m for help): nFirst cylinder (10882-13054, default 10882): Using default value 10882Last cylinder, + cylinders or + size {KMagazine G} Default 13054): + 1GCommand (m for help): tPartition number (1-8): 8Hex code (type L to list codes): fdChanged system type of partition 8 to fd (Linux raid autodetect) Command (m for help): tPartition number (1-8): 7Hex code (type L to list codes): fdChanged system type of partition 7 to fd (Linux raid autodetect) Command (m for help): tPartition number (1-8): 6Hex code (type L to list codes): fdChanged system type of partition 6 to fd (Linux raid autodetect) Command ( M for help): tPartition number (1-8): 5 Hex code (type L to list codes): fdChanged system type of partition 5 to fd (Linux raid autodetect) Command (m for help): P Disk / dev/sda: 107.4 GB 107374182400 bytes255 heads, 63 sectors/track 13054 cylindersUnits = cylinders of 16065 * 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0008ed57 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 10225 81920000 83 Linux/dev/sda3 10225 10486 2097152 82 Linux swap / Solaris/dev/sda4 10486 13054 20633279 5 Extended/dev/sda5 10486 10617 1058045 fd Linux raid autodetect/dev/sda6 10618 10749 1060258 + fd Linux raid autodetect/dev/sda7 10750 10881 1060258 + fd Linux raid autodetect/dev/sda8 10882 11013 1060258 + fd Linux raid autodetectCommand (m for help) : wThe partition table has been altered calling ioctl () to re-read partition table.WARNING: Re-reading the partition table failed with error 16: busy equipment or resources. The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe (8) or kpartx (8) Syncing disks.
4.2 load the kernel
[root@xiao] # partx-a / dev/sda5 / dev/sda
[root@xiao] # partx-a / dev/sda6 / dev/sda
[root@xiao] # partx-a / dev/sda7 / dev/sda
[root@xiao] # partx-a / dev/sda8 / dev/sda
4.3.Create raid5 and its hot spare
[root@xiao] # mdadm-C / dev/md0-l 5-n 3-x 1 / dev/sda {5pct 6 7,8} mdadm: / dev/sda5 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014mdadm: / dev/sda6 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014mdadm: / dev/sda7 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014mdadm: / dev/sda8 appears to be part of a raid array: level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014Continue creating array? Ymdadm: Defaulting to version 1.2 metadatamdadm: array / dev/md0 started.
4.4.The initialization time is related to the read and write application of the disk array, using cat / proc/mdstat information to query the current reconfiguration speed and expected completion time of the RAID array.
[root@xiao ~] # cat / proc/mdstatPersonalities: [raid1] [raid0] [raid6] [raid4] md0: active raid5 sda7 [4] sda8 [3] (S) sda6 [1] sda5 [0] 2113536 blocks super 1.2 level 5,512k chunk, algorithm 2 [3max 2] [UU_] [= >.] Recovery = 45.5% (482048 CP1056768) finish=0.3min speed=30128K/sec unused devices: [root@xiao ~] # cat / proc/mdstatPersonalities: [raid1] [raid0] [raid6] [raid5] [raid4] md0: active raid5 sda7 [4] sda8 [3] (S) sda6 [1] sda5 [0] 2113536 blocks super 1.2 level 5,512k chunk Algorithm 2 [3bat 3] [UUU] unused devices: [root@xiao ~] # mke2fs-t ext3 / dev/md0 / / format raid
4.5 Mount raid to the / mnt directory and check whether it is normal (shows that lost+found is normal)
[root@xiao ~] # mount / dev/md0 / mnt [root@xiao ~] # ls / mntlost+found
4.6 View details of the raid array
[root@xiao] # mdadm-D / dev/md0/dev/md0: Version: 1.2 Creation Time: Wed Dec 17 03:38:08 2014 Raid Level: raid5 Array Size: 2113536 (2.02 GiB 2.16 GB) Used Dev Size: 1056768 (1032.17 MiB 1082.13 MB) Raid Devices: 3 Total Devices: 4 Persistence: Superblock is persistent Update Time: Wed Dec 17 03:55:11 2014 State: clean Active Devices: 3Working Devices: 4 Failed Devices: 0 Spare Devices: 1 Layout: left-symmetric Chunk Size: 512K Name: xiao:0 (local to host xiao) UUID: bce110f2:34f3fbf1:8de472ed:633a374f Events: 18 Number Major Minor RaidDevice State 0 8 50 active sync / dev/sda5 18 6 1 active sync / dev/sda6 4 8 7 2 active sync / dev/sda7 3 8 8-spare / dev/sda8
4.7 simulated damage to one of the disks, here I choose / dev/sda6 disk
[root@xiao] # mdadm / dev/md0-- fail / dev/sda6mdadm: set / dev/sda6 faulty in / dev/md0
4.7 View the raid array details and find that / dev/sda8 automatically replaces the damaged / dev/sda6 disk.
[root@xiao] # mdadm-D / dev/md0/dev/md0: Version: 1.2 Creation Time: Wed Dec 17 03:38:08 2014 Raid Level: raid5 Array Size: 2113536 (2.02 GiB 2.16 GB) Used Dev Size: 1056768 (1032.17 MiB 1082.13 MB) Raid Devices: 3 Total Devices: 4 Persistence: Superblock is persistent Update Time: Wed Dec 17 04:13:59 2014 State: clean, degraded Recovering Active Devices: 2Working Devices: 3 Failed Devices: 1 Spare Devices: 1 Layout: left-symmetric Chunk Size: 512K Rebuild Status: 43% complete Name: xiao:0 (local to host xiao) UUID: bce110f2:34f3fbf1:8de472ed:633a374f Events: 26 Number Major Minor RaidDevice State 0 8 50 active sync / dev/sda5 3 8 8 1 spare rebuilding / dev/sda8 48 7 2 active sync / dev/sda7 18 6-faulty / dev/sda6 [root@xiao ~] # cat / proc/mdstatPersonalities: [raid1] [raid0] [raid6] [raid5] [raid4] md0: active raid5 sda7 [4] sda8 [3] sda6 [1] (F) sda5 [0]
2113536 blocks super 1.2 level 5,512k chunk, algorithm 2 [3ax 3] [UUU] # normally [UUU], if the first disk is damaged, it will show [_ UU].
4.8 remove damaged hard drives
[root@xiao] # mdadm / dev/md0-r / dev/sda6mdadm: hot removed / dev/sda6 from / dev/md0
4.9 add a new hard disk as a hot spare
[root@xiao ~] # fdisk / dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): nFirst cylinder (11014-13054, default 11014): Using default value 11014Last cylinder, + cylinders or + size {K mai M Magi G} (11014-13054) Default 13054): + 1GCommand (m for help): tPartition number (1-9): 9Hex code (type L to list codes): fdChanged system type of partition 9 to fd (Linux raid autodetect) Command (m for help): pDisk / dev/sda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track 13054 cylindersUnits = cylinders of 16065 * 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0008ed57 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 10225 81920000 83 Linux/dev/sda3 10225 10486 2097152 82 Linux swap / Solaris/dev/sda4 10486 13054 20633279 5 Extended/dev/sda5 10486 10617 1058045 fd Linux raid autodetect/dev/sda6 10618 10749 1060258 + fd Linux raid autodetect/dev/sda7 10750 10881 1060258 + fd Linux raid autodetect/dev/sda8 10882 11013 1060258 + fd Linux raid autodetect/dev/sda9 11014 11145 1060258 + fd Linux raid autodetectCommand (m for help): wThe partition table has been altered calling ioctl () to re-read partition table.WARNING: Re-reading the partition table failed with error 16: busy equipment or resources. The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe (8) or kpartx (8) Syncing disks. [root@xiao ~] # partx-a / dev/sda9 / dev/sda [root@xiao ~] # mdadm / dev/md0-- add / dev/sda9mdadm: added / dev/sda9 [root@xiao ~] # mdadm-D / dev/md0/dev/md0: Version: 1.2 Creation Time: Wed Dec 17 03:38:08 2014 Raid Level: raid5 Array Size: 2113536 (2.02 GiB 2.16 GB) Used Dev Size: 1056768 (1032.17 MiB 1082.13 MB) Raid Devices: 3 Total Devices: 4 Persistence: Superblock is persistent Update Time: Wed Dec 17 04:39:35 2014 State: clean Active Devices: 3Working Devices: 4 Failed Devices: 0 Spare Devices: 1 Layout: left-symmetric Chunk Size: 512K Name: xiao:0 (local to host xiao) UUID: bce110f2:34f3fbf1:8de472ed 633a374f Events: 41 Number Major Minor RaidDevice State 0 8 50 active sync / dev/sda5 3 8 8 1 active sync / dev/sda8 4 8 7 2 active sync / dev/sda7 58 9-spare / dev/sda9
5. Power on and mount automatically
Edit / etc/fsab file
/ dev/md0 / mnt ext3 defaults 0 0
: wq
6.mdadm Chinese man (reference)
Basic syntax: mdadm [mode] [options]
[mode] there are 7 kinds:
Assemble: adds a previously defined array to the currently active array.
Build:Build a legacy array, no superblocks per device
Create: create a new array with superblocks for each device
Manage: manage arrays, such as add or remove
Misc: allows individual operations on a device in the array, such as erasing the superblocks or terminating the array in use.
Follow or Monitor: monitor the status of raid 1, 4, 5, 6 and multipath
Grow: change the raid capacity or the number of device in the array
Available [options]:
-A,-- assemble: join a previously defined array
-B.-- build:Build a legacy array without superblocks.
-C,-- create: create a new array
-Q,-- query: look at a device and determine whether it is a md device or part of a md array
-D,-- detail: print the details of one or more md device
-E,-- examine: print the contents of md superblock on device
-F,-- follow,-- monitor: select Monitor mode
-G,-- grow: change the size or shape of the array in use
-h,-- help: help information, which is displayed when used in the above option
-- help-options
-V-- version
-v,-- verbose: show details
-b,-- brief: fewer details. For-- detail and-- examine options
-f,-- force
-c,-- config=: specify the configuration file. Default is / etc/mdadm/mdadm.conf.
-s,-- scan: scan the configuration file or / proc/mdstat for missing information. Configuration file / etc/mdadm/mdadm.conf
Options used by create or build:
-c,-- chunk=:Specify chunk size of kibibytes. The default is 64.
-- rounding=: Specify rounding factor for linear array (= = chunk size)
-l,-- level=: sets raid level.
-- create available: linear, raid0, 0, stripe, raid1,1, mirror, raid4, 4, raid5, 5, raid6, 6, multipath, mp.
-- build available: linear, raid0, 0, stripe.
-p,-- parity=: sets raid5 parity rules: eft-asymmetric, left-symmetric, right-asymmetric, right-symmetric, la, ra, ls, rs. The default is left-symmetric
-- layout=: similar to-- parity
-n,-- raid-devices=: specifies the number of device available in the array, which can only be modified by-- grow
-x,-- spare-devices=: specifies the number of redundant device of the initial array
-z,-- the total number of spaces obtained from each RAID1/4/5/6 after size=: builds the device
-- assume-clean: currently available only for-- build option
-R,-- run: when a portion of an array appears in another array or file system, mdadm acknowledges the array. This option will not be confirmed.
-f,-- force: usually mdadm does not allow an array to be created with only one device, and a device is used as the missing drive when creating a raid5. This option is just the opposite.
-a,-- auto {= no,yes,md,mdp,part,p} {NN}:
What is the role of the mdadm command is shared here, I hope that the above content can have a certain reference value for everyone, you can learn to apply. If you like this article, you might as well share it for more people to see.
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.