mdadm 명령에 대한 자세한 설명

藏色散人
풀어 주다: 2020-02-20 09:45:51
원래의
10667명이 탐색했습니다.

mdadm 명령에 대한 자세한 설명

mdadm 명령어 상세 설명

mdadm 명령어 상세 설명 및 실험 과정

#🎜🎜 #온라인 학습 영상 공유:

linux video tutorial

1. 개념

mdadm은 Multiple Devices Admin의 약어로, 아래의 표준입니다. Neil Brown이 작성한 Linux 소프트웨어 RAID 관리 도구 분산된 프로그램 모음이 아닌 단일 통합 프로그램이므로 다양한 RAID 관리 명령에 대한 공통 구문이 있습니다.

mdadm은 필요 없이 거의 모든 기능을 수행할 수 있습니다. 구성 파일(및 기본 구성 파일 없음)

3. 기능(인용)

Linux 시스템에서 소프트웨어 RAID는 현재 MD(Multiple Devices) 형식으로 구현됩니다. ) 여러 기본 블록을 사용하는 가상 블록 장치 장치는 새로운 가상 장치를 가상화하고 스트라이핑 기술을 사용하여 데이터 블록을 여러 디스크에 균등하게 분산하여 가상 장치의 읽기 및 쓰기 성능을 향상시키고 다양한 데이터 중복 알고리즘을 사용하여 사용자 데이터를 보호합니다. 블록 장치 오류로 인한 전체 손실로 인한 손실을 방지하고 장치 교체 후 손실된 데이터를 새 장치에 복원할 수 있습니다.

현재 MD는 선형, 다중 경로, raid0(스트리핑)을 지원합니다. , raid1(미러), raid4, raid5, raid6, raid10 및 기타 다양한 중복 수준 및 등급 지정 방법은 물론 여러 RAID 어레이를 계단식으로 연결하여 raid1 0, raid5 1 및 기타 유형의 어레이를 형성하는 것도 지원할 수 있습니다#🎜🎜 #

4. 실험

질문: 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 /mnt 디렉터리에 레이드를 마운트하고 정상인지 확인합니다(lost+found는 정상적으로 표시됩니다)

[root@xiao ~]# mount /dev/md0 /mnt
[root@xiao ~]# ls /mnt
lost+found
로그인 후 복사

4.6 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 디스크 중 하나의 손상을 시뮬레이션합니다. 여기서는 /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 [모드] [옵션]

#🎜 🎜#[mode ] 7가지 종류가 있습니다.

Assemble: 현재 사용되는 배열에 이전에 정의한 배열을 추가합니다.

빌드: 레거시 어레이 구축, 각 장치에 슈퍼 블록 없음

Create: 새 어레이 생성, 각 장치에 슈퍼 블록 있음

관리: 관리 추가 또는 제거와 같은 어레이

Misc: 슈퍼블록 삭제 또는 사용 중인 어레이 종료와 같은 어레이의 장치에 대한 개별 작업을 허용합니다.

Follow 또는 Monitor: raid 1,4,5,6 및 다중 경로 상태 모니터링

Grow: raid 용량 또는 어레이의 장치 수 변경#🎜 🎜##🎜 🎜#Available [옵션]:

-A, --assemble: 이전에 정의된 배열 추가

-B, --build: 레거시 배열 구축 슈퍼블록 없이 .

-C, --create: 새 배열 만들기

-Q, --query: 장치를 보고 그것이 md 장치인지 확인합니다. md 배열의 일부

-D, --detail: 하나 이상의 md 장치에 대한 자세한 정보를 인쇄합니다.

-E, --examine: md 슈퍼블록을 인쇄합니다. device Content

-F, --follow, --monitor: 모니터 모드 선택

-G, --grow: 사용 중인 어레이의 크기나 모양 변경# 🎜🎜#

-h, --help: 도움말 정보, 위 옵션과 함께 사용 시 옵션 정보가 표시됩니다.

--help-options

#🎜🎜 #-V, - -version

-v, --verbose: 세부 정보 표시

-b, --brief: 세부 정보가 적습니다. --detail 및 --examine 옵션에 사용됨

-f, --force

-c, --config=: 구성 파일을 지정합니다. 기본값은 /etc입니다. / mdadm/mdadm.conf

-s, --scan: 누락된 정보가 있는지 구성 파일 또는 /proc/mdstat를 스캔합니다. 구성 파일 /etc/mdadm/mdadm.conf

create 또는 빌드 옵션 사용:

-c, --chunk=:청크 크기를 킬로바이트로 지정합니다. 기본값은 64입니다. .

--rounding=: 선형 배열에 대한 반올림 인수 지정(==청크 크기)

-l, --level=: raid 수준을 설정합니다.

--사용 가능 생성: 선형, raid0, 0, 스트라이프, raid1, 1 , 미러, raid4, 4, raid5, 5, raid6, 6, multipath, mp.

--빌드 사용 가능: 선형, raid0, 0, 스트라이프.

-p, --parity=: raid5의 패리티 설정 규칙: eft 비대칭, 왼쪽 대칭, 오른쪽 비대칭, 오른쪽 대칭, la, ra, ls, rs. 기본값은 왼쪽 대칭

--layout=: --parity

-n 과 유사합니다. -raid-devices=: 배열에서 사용 가능한 장치 수를 지정합니다. 이 숫자는 --grow

-x로만 수정할 수 있습니다. --spare-devices=: 초기 배열의 예비 장치 수를 지정합니다

-z, -- size=: RAID1/4/5/6

설정 후 각 장치에서 얻은 총 공간량

--assume-clean: 현재 --build 옵션

-R에만 사용됩니다. - -run: mdadm 배열의 특정 부분은 다른 배열이나 파일 시스템에 존재할 때 배열을 인식합니다. 이 옵션은 확인하지 않습니다.

-f, --force: 일반적으로 mdadm은 하나의 장치만으로 어레이 생성을 허용하지 않으며, raid5를 생성할 때 하나의 장치가 누락된 드라이브로 사용됩니다. 이 옵션은 정반대입니다.

-a, --auto{=no,yes,md,mdp,part,p}{NN}:더 많은 프로그래밍 관련 내용을 보려면 PHP 중국어 웹사이트

프로그래밍 소개🎜 칼럼을 주목해주세요! 🎜

위 내용은 mdadm 명령에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!