mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-22 23:00:57 +08:00
translated
This commit is contained in:
parent
c8d807eb0f
commit
48f07e8a7a
@ -1,99 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Managing RAID arrays with mdadm)
|
||||
[#]: via: (https://fedoramagazine.org/managing-raid-arrays-with-mdadm/)
|
||||
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
|
||||
|
||||
Managing RAID arrays with mdadm
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
Mdadm stands for Multiple Disk and Device Administration. It is a command line tool that can be used to manage software [RAID][2] arrays on your Linux PC. This article outlines the basics you need to get started with it.
|
||||
|
||||
The following five commands allow you to make use of mdadm’s most basic features:
|
||||
|
||||
1. **Create a RAID array** :
|
||||
### mdadm --create /dev/md/test --homehost=any --metadata=1.0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
|
||||
2. **Assemble (and start) a RAID array** :
|
||||
### mdadm --assemble /dev/md/test /dev/sda1 /dev/sdb1
|
||||
3. **Stop a RAID array** :
|
||||
### mdadm --stop /dev/md/test
|
||||
4. **Delete a RAID array** :
|
||||
### mdadm --zero-superblock /dev/sda1 /dev/sdb1
|
||||
5. **Check the status of all assembled RAID arrays** :
|
||||
### cat /proc/mdstat
|
||||
|
||||
|
||||
|
||||
#### Notes on features
|
||||
|
||||
##### `mdadm --create`
|
||||
|
||||
The _create_ command shown above includes the following four parameters in addition to the create parameter itself and the device names:
|
||||
|
||||
1. **–homehost** :
|
||||
By default, mdadm stores your computer’s name as an attribute of the RAID array. If your computer name does not match the stored name, the array will not automatically assemble. This feature is useful in server clusters that share hard drives because file system corruption usually occurs if multiple servers attempt to access the same drive at the same time. The name _any_ is reserved and disables the _homehost_ restriction.
|
||||
2. **–metadata** :
|
||||
_mdadm_ reserves a small portion of each RAID device to store information about the RAID array itself. The _metadata_ parameter specifies the format and location of the information. The value _1.0_ indicates to use version-1 formatting and store the metadata at the end of the device.
|
||||
3. **–level** :
|
||||
The _level_ parameter specifies how the data should be distributed among the underlying devices. Level _1_ indicates each device should contain a complete copy of all the data. This level is also known as [disk mirroring][3].
|
||||
4. **–raid-devices** :
|
||||
The _raid-devices_ parameter specifies the number of devices that will be used to create the RAID array.
|
||||
|
||||
|
||||
|
||||
By using _level=1_ (mirroring) in combination with _metadata=1.0_ (store the metadata at the end of the device), you create a RAID1 array whose underlying devices appear normal if accessed without the aid of the mdadm driver. This is useful in the case of disaster recovery, because you can access the device even if the new system doesn’t support mdadm arrays. It’s also useful in case a program needs _read-only_ access to the underlying device before mdadm is available. For example, the [UEFI][4] firmware in a computer may need to read the bootloader from the [ESP][5] before mdadm is started.
|
||||
|
||||
##### `mdadm --assemble`
|
||||
|
||||
The _assemble_ command above fails if a member device is missing or corrupt. To force the RAID array to assemble and start when one of its members is missing, use the following command:
|
||||
|
||||
```
|
||||
# mdadm --assemble --run /dev/md/test /dev/sda1
|
||||
```
|
||||
|
||||
#### Other important notes
|
||||
|
||||
Avoid writing directly to any devices that underlay a mdadm RAID1 array. That causes the devices to become out-of-sync and mdadm won’t know that they are out-of-sync. If you access a RAID1 array with a device that’s been modified out-of-band, you can cause file system corruption. If you modify a RAID1 device out-of-band and need to force the array to re-synchronize, delete the mdadm metadata from the device to be overwritten and then re-add it to the array as demonstrated below:
|
||||
|
||||
```
|
||||
# mdadm --zero-superblock /dev/sdb1
|
||||
# mdadm --assemble --run /dev/md/test /dev/sda1
|
||||
# mdadm /dev/md/test --add /dev/sdb1
|
||||
```
|
||||
|
||||
These commands completely overwrite the contents of sdb1 with the contents of sda1.
|
||||
|
||||
To specify any RAID arrays to automatically activate when your computer starts, create an _/etc/mdadm.conf_ configuration file.
|
||||
|
||||
For the most up-to-date and detailed information, check the man pages:
|
||||
|
||||
```
|
||||
$ man mdadm
|
||||
$ man mdadm.conf
|
||||
```
|
||||
|
||||
The next article of this series will show a step-by-step guide on how to convert an existing single-disk Linux installation to a mirrored-disk installation, that will continue running even if one of its hard drives suddenly stops working!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/managing-raid-arrays-with-mdadm/
|
||||
|
||||
作者:[Gregory Bartholomew][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/glb/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/mdadm-816x345.jpg
|
||||
[2]: https://en.wikipedia.org/wiki/RAID
|
||||
[3]: https://en.wikipedia.org/wiki/Disk_mirroring
|
||||
[4]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
|
||||
[5]: https://en.wikipedia.org/wiki/EFI_system_partition
|
105
translated/tech/20190417 Managing RAID arrays with mdadm.md
Normal file
105
translated/tech/20190417 Managing RAID arrays with mdadm.md
Normal file
@ -0,0 +1,105 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Managing RAID arrays with mdadm)
|
||||
[#]: via: (https://fedoramagazine.org/managing-raid-arrays-with-mdadm/)
|
||||
[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/)
|
||||
|
||||
使用 mdadm 管理 RAID 阵列
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
mdadm 代表多磁盘和设备管理 (Multiple Disk and Device Administration)。它是一个命令行工具,可用于管理 Linux 上的软件 [RAID][2] 阵列。本文概述了使用它的基础知识。
|
||||
|
||||
以下 5 个命令是你使用 mdadm 的基础功能:
|
||||
|
||||
1. **创建 RAID 阵列**:
|
||||
### mdadm --create /dev/md/test --homehost=any --metadata=1.0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
|
||||
|
||||
2. **组合(并启动)RAID 阵列**:
|
||||
### mdadm --assemble /dev/md/test /dev/sda1 /dev/sdb1
|
||||
|
||||
3. **停止 RAID 阵列**:
|
||||
### mdadm --stop /dev/md/test
|
||||
|
||||
4. **删除 RAID 阵列**:
|
||||
### mdadm --zero-superblock /dev/sda1 /dev/sdb1
|
||||
|
||||
5. **检查所有已组合的 RAID 阵列的状态**:
|
||||
### cat /proc/mdstat
|
||||
|
||||
|
||||
|
||||
#### 功能说明
|
||||
|
||||
##### `mdadm --create`
|
||||
|
||||
上面的 _create_ 命令除了 create 参数自身和设备名之外,还包括了四个参数:
|
||||
|
||||
1. **–homehost** :
|
||||
默认情况下,mdadm 将你的计算机名保存为 RAID 阵列的属性。如果你的计算机名与存储的名称不匹配,则阵列将不会自动组合。此功能在共享硬盘的服务器群集中很有用,因为如果多个服务器同时尝试访问同一驱动器,通常会发生文件系统损坏。名称 _any_ 是保留字段并禁用 _homehost_ 限制。
|
||||
|
||||
2. **–metadata** :
|
||||
_mdadm_ 保存每个 RAID 设备的一小部分,以存储有关 RAID 阵列本身的信息。 _metadata_ 参数指定信息的格式和位置。_1.0_ 表示使用版本 1 格式并将元数据存储在设备的末尾。
|
||||
|
||||
3. **–level** :
|
||||
_level_ 参数指定数据应如何在底层设备之间分布。级别 _1_ 表示每个设备应包含所有数据的完整副本。此级别也称为[磁盘镜像] [3]。
|
||||
|
||||
4. **–raid-devices** :
|
||||
_raid-devices_ 参数指定将用于创建 RAID 阵列的设备数。
|
||||
|
||||
|
||||
通过将 _level=1_ (镜像)与 _metadata=1.0_ (将元数据存储在设备末尾)结合使用,可以创建一个 RAID1 阵列,如果不通过 mdadm 驱动访问,那么它的底层设备会正常显示。这在灾难恢复的情况下很有用,因为即使新系统不支持 mdadm 阵列,你也可以访问该设备。如果程序需要在 mdadm 可用之前以_只读_访问底层设备时也很有用。例如,计算机中的 [UEFI][4] 固件可能需要在启动 mdadm 之前从 [ESP][5] 读取引导加载程序。
|
||||
|
||||
##### `mdadm --assemble`
|
||||
|
||||
如果成员设备丢失或损坏,上面的 _assemble_ 命令将失败。要强制 RAID 阵列在其中一个成员丢失时进行组合并启动,请使用以下命令:
|
||||
|
||||
```
|
||||
# mdadm --assemble --run /dev/md/test /dev/sda1
|
||||
```
|
||||
|
||||
#### 其他重要说明
|
||||
|
||||
避免直接写入底层是 RAID1 的设备。这导致设备不同步,并且 mdadm 不会知道它们不同步。如果你访问了某个在其他地方被修改的设备的 RAID1 阵列,则可能导致文件系统损坏。如果你在其他地方修改 RAID1 设备并需要强制阵列重新同步,请从要覆盖的设备中删除 mdadm 元数据,然后将其重新添加到阵列,如下所示:
|
||||
|
||||
```
|
||||
# mdadm --zero-superblock /dev/sdb1
|
||||
# mdadm --assemble --run /dev/md/test /dev/sda1
|
||||
# mdadm /dev/md/test --add /dev/sdb1
|
||||
```
|
||||
|
||||
以上用 sda1 的内容完全覆盖 sdb1 的内容。
|
||||
|
||||
要指定在计算机启动时自动激活的 RAID 阵列,请创建 _/etc/mdadm.conf_ 配置。
|
||||
|
||||
有关最新和详细信息,请查看手册页:
|
||||
|
||||
```
|
||||
$ man mdadm
|
||||
$ man mdadm.conf
|
||||
```
|
||||
|
||||
本系列的下一篇文章将展示如何将现有的单磁盘 Linux 安装变为镜像磁盘安装,这意味着即使其中一个硬盘突然停止工作,系统仍将继续运行!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/managing-raid-arrays-with-mdadm/
|
||||
|
||||
作者:[Gregory Bartholomew][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/glb/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/mdadm-816x345.jpg
|
||||
[2]: https://en.wikipedia.org/wiki/RAID
|
||||
[3]: https://en.wikipedia.org/wiki/Disk_mirroring
|
||||
[4]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
|
||||
[5]: https://en.wikipedia.org/wiki/EFI_system_partition
|
Loading…
Reference in New Issue
Block a user