ホームページ  >  記事  >  運用・保守  >  mdadmコマンドの詳しい説明

mdadmコマンドの詳しい説明

藏色散人
藏色散人オリジナル
2020-02-20 09:45:5110640ブラウズ

mdadmコマンドの詳しい説明

mdadm コマンドの詳細な説明

mdadm コマンドと実験プロセスの詳細な説明

オンライン学習ビデオ共有:linux ビデオ チュートリアル

1. 概念

mdadm は、multiple devices admin の略で、Linux の標準的なソフトウェア RAID 管理ツールです。作者は Neil Brown

です。

2. 機能

mdadm は、アレイの詳細情報を診断、監視、収集できます

mdadm は、分散したプログラムの集合ではなく、個別に統合されたプログラムであるため、さまざまな RAID に共通のコマンドがありますManagement 構文

mdadm は、設定ファイルなしでほぼ​​すべての機能を実行できます (デフォルトの設定ファイルはありません)

3. 機能 (参考)

Linux システムでは、現在、ソフトウェア RAID は、MD (マルチデバイス) 仮想ブロック デバイスの形式で実装されます。複数の基盤となるブロック デバイスを使用して新しい仮想デバイスを仮想化し、ストライピング テクノロジを使用してデータ ブロックを複数のディスクに均等に分散します。読み取りおよび書き込みのパフォーマンスが向上します。 .

現在、MD は線形、マルチパス、raid0 (ストリッピング)、raid1 (ミラー)、raid4、raid5、raid6、raid10、およびその他の異なる冗長レベルとグレーディング方法。もちろん、複数の RAID アレイもサポートできます。カスケードは、raid1 0、raid5 1、およびraid5 のアレイを形成します。その他のタイプ.

IV. 実験

テスト問題: サイズ 1G のディスクを 4 台作成し、そのうち 3 台を Raid5 アレイ ディスクとして作成し、1 台はホット スペア ディスクとして使用します。ホット スペア ディスクをテストしてアレイ内のディスクを交換し、データを同期します。破損したディスクを取り外し、新しいディスクをホット スペアとして追加します。最後に、起動時に自動的にマウントされる必要があります。

4.1ディスクの作成

 [root@xiao ~]# fdisk /dev/sda
WARNING: 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): n
First cylinder (10486-13054, default 10486): 
Using default value 10486
Last cylinder, +cylinders or +size{K,M,G} (10486-13054, default 13054): +1G
Command (m for help): n
First cylinder (10618-13054, default 10618): 
Using default value 10618
Last cylinder, +cylinders or +size{K,M,G} (10618-13054, default 13054): +1G
Command (m for help): n
First cylinder (10750-13054, default 10750): 
Using default value 10750
Last cylinder, +cylinders or +size{K,M,G} (10750-13054, default 13054): +1G
Command (m for help): n
First cylinder (10882-13054, default 10882): 
Using default value 10882
Last cylinder, +cylinders or +size{K,M,G} (10882-13054, default 13054): +1G
Command (m for help): t
Partition number (1-8): 8
Hex code (type L to list codes): fd
Changed system type of partition 8 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-8): 7
Hex code (type L to list codes): fd
Changed system type of partition 7 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-8): 6
Hex code (type L to list codes): fd
Changed system type of partition 6 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-8): 5  
Hex code (type L to list codes): fd
Changed system type of partition 5 to fd (Linux raid autodetect)
Command (m for help): p 
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008ed57
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 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
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: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

4.2カーネルのロード

[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 Raid5 とそのホット バックアップ ディスクを作成します

[root@xiao ~]# mdadm -C /dev/md0 -l 5 -n 3 -x 1   /dev/sda{5,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 2014
mdadm: /dev/sda6 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014
mdadm: /dev/sda7 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014
mdadm: /dev/sda8 appears to be part of a raid array:
    level=raid5 devices=3 ctime=Wed Dec 17 00:58:24 2014
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

4.4 初期化時間は、アプリケーションの読み取りおよび書き込みに関連します。ディスク アレイの場合は、cat /proc/mdstat 情報を使用して、RAID アレイの現在の再構築速度と予想される完了時間をクエリします。

[root@xiao ~]# cat /proc/mdstat
Personalities : [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 [3/2] [UU_]
      [=========>...........]  recovery = 45.5% (482048/1056768) finish=0.3min speed=30128K/sec
      
unused devices: <none>
[root@xiao ~]# cat /proc/mdstat
Personalities : [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 [3/3] [UUU]
      
unused devices: <none>
 [root@xiao ~]# mke2fs -t ext3 /dev/md0        //格式化raid

4.5 RAID を /mnt ディレクトリにマウントし、正常か確認します (lost found は正常と表示されます)

[root@xiao ~]# mount /dev/md0 /mnt
[root@xiao ~]# ls /mnt
lost+found

4.6 RAID の詳細情報を確認します。 RAID アレイ

[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 : 3
Working 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        5        0      active sync   /dev/sda5
       1       8        6        1      active sync   /dev/sda6
       4       8        7        2      active sync   /dev/sda7
       3       8        8        -      spare   /dev/sda8

4.7 ディスクの 1 つへの損傷をシミュレートします。ここでは、/dev/sda6 ディスクを選択します。

[root@xiao ~]# mdadm /dev/md0 --fail /dev/sda6
mdadm: set /dev/sda6 faulty in /dev/md0

4.7 RAID アレイの詳細を確認し、/dev/sda8 が自動的に置き換えられることを確認します。 /dev/sda6 ディスクが破損しています。

[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 : 2
Working 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        5        0      active sync   /dev/sda5
       3       8        8        1      spare rebuilding   /dev/sda8
       4       8        7        2      active sync   /dev/sda7
       1       8        6        -      faulty   /dev/sda6
[root@xiao ~]# cat /proc/mdstat
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4] 
md0 : active raid5 sda7[4] sda8[3] sda6[1](F) sda5[0]

2113536 ブロック スーパー 1.2 レベル 5、512k チャンク、アルゴリズム 2 [3/3] [UUU] #通常の状況は [UUU] ですが、最初のディスクが破損している場合は [_UU] と表示されます.

4.8 破損したハードディスクを取り外します

[root@xiao ~]# mdadm /dev/md0 -r /dev/sda6
mdadm: hot removed /dev/sda6 from /dev/md0

4.9 新しいハードディスクをホット バックアップ ディスクとして追加します

[root@xiao ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It&#39;s strongly recommended to
         switch off the mode (command &#39;c&#39;) and change display units to
         sectors (command &#39;u&#39;).
Command (m for help): n
First cylinder (11014-13054, default 11014): 
Using default value 11014
Last cylinder, +cylinders or +size{K,M,G} (11014-13054, default 13054): +1G
Command (m for help): t
Partition number (1-9): 9
Hex code (type L to list codes): fd
Changed system type of partition 9 to fd (Linux raid autodetect)
Command (m for help): p
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008ed57
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 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 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: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the 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/sda9
mdadm: 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 : 3
Working 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        5        0      active sync   /dev/sda5
       3       8        8        1      active sync   /dev/sda8
       4       8        7        2      active sync   /dev/sda7
       5       8        9        -      spare   /dev/sda9

5. ブート時に自動的にマウント

/etc/ fsab ファイル

/dev/md0 /mnt ext3 のデフォルトは 0 0

:wq

6 を編集します。 mdadm 中国人(引用)

基本構文: mdadm [モード] [オプション]

[モード] 7種類あります:

アセンブル: 事前に定義した配列を追加します。現在使用されている 1 つの配列。

Build: 従来のアレイを構築します。各デバイスにはスーパーブロックはありません。

Create: 新しいアレイを作成します。各デバイスにはスーパーブロックがあります。

Manage: アレイを管理します (追加など)。または、remove

Misc: スーパーブロックの消去や使用中のアレイの終了など、アレイ内のデバイスに対する個別の操作を許可します。

フォローまたは監視: RAID 1、4、5、6 およびマルチパスのステータスを監視します

拡張: RAID 容量またはアレイ内のデバイスの数を変更します

利用可能な [オプション]:

-A、--assemble:以前に定義した配列を追加します

-B、--build:スーパーブロックなしでレガシー配列を構築します。

- C、--create: 新しいアレイを作成します

-Q、--query: デバイスをチェックして、それが md デバイスであるか md アレイの一部であるかを判断します

-D, - - 詳細: 1 つ以上の md デバイスの詳細情報を出力します。

-E、--examine: デバイス上の md スーパーブロックの内容を出力します。

#-F、--follow、- -monitor: モニター モードを選択します。

-G、--grow: 使用する配列のサイズまたは形状を変更します。

#-h、--help: ヘルプ情報。このオプションが表示されます。上記のオプションを使用した後、 info

--help-options

-V、--version

-v、--verbose: 詳細を表示

-b、--簡潔: 詳細が少なくなります。 --detail および --examine オプション

-f、--force

-c、--config= の場合、構成ファイルを指定します。デフォルトは /etc/mdadm/mdadm です。 conf

-s、--scan: 構成ファイルまたは /proc/mdstat をスキャンして、不足している情報を探します。構成ファイル /etc/mdadm/mdadm.conf

作成またはビルドで使用されるオプション:

-c, --chunk=:キビバイトのチャンク サイズを指定します。デフォルトは 64.

--rounding=: 線形配列の丸め係数を指定します (== チャンク サイズ)

-l, --level=: RAID レベルを設定します。

--create available: Linear 、raid0、0、ストライプ、raid1、1、ミラー、raid4、4、raid5、5、raid6、6、マルチパス、mp.

--利用可能なビルド: リニア、raid0、0、ストライプ。

-p, --parity=:raid5 のパリティ チェック ルールを設定します: eft-ametric、left-metric、right-ametric、right-metric、la、ra、ls、rs。デフォルトは left-metric です。

--layout=: --parity

-n と同様、--raid-devices=: アレイ内で使用可能なデバイスの数を指定します。この数は - によってのみ変更できます。 -grow

-x、--spare-devices=: 初期アレイのスペア デバイスの数を指定します。

-z、--size=: RAID1/4/5 セットアップ後/6、各デバイスからスペア デバイスの数を削除します。 獲得した合計スペース

##--assume-clean: 現在、 --build オプションでのみ使用されます。

#-R、 --run: 特定の配列の一部が他の配列またはファイル システムにある場合、mdadm は配列を確認します。このオプションは確定しません。

-f, --force: 通常、mdadm では 1 つのデバイスのみでアレイを作成することはできず、RAID5 を作成するときに 1 つのデバイスが不足しているドライブとして使用されます。このオプションはその逆です。

-a, --auto{=no,yes,md,mdp,part,p}{NN}:

プログラミング関連のコンテンツの詳細については、php 中国語 Web サイトにご注意ください

プログラミング入門

コラム!

以上がmdadmコマンドの詳しい説明の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。