재부팅 후 LVM의 기반이 되는 mdadm RAID가 사라짐

재부팅 후 LVM의 기반이 되는 mdadm RAID가 사라짐

제 문제의 주요 부분은 저번에 여기서 논의된 적이 있습니다... ... 하지만 이전에 답변을 받지 못한 두 가지 특별한 질문이 있습니다.

상황: 하드웨어를 업그레이드하고 두 개의 새 디스크를 설치하고 설정을 변경했습니다.

이것이새로운설정

PROMPT> blkid
/dev/nvme0n1p3: UUID="29cd2fd5-2cd5-455c-9ac0-7cb278e46ee3" TYPE="swap" PARTUUID="dc3d569d-363f-4f68-87ac-56e1bdb4f29d"
/dev/nvme0n1p1: UUID="D2F8-117C" TYPE="vfat" PARTUUID="cdc50870-bddc-47bf-9835-369694713e41"
/dev/nvme0n1p2: UUID="e36edd7b-d3fd-45f4-87a8-f828238aab08" TYPE="ext4" PARTUUID="25d98b84-55a1-4dd8-81c1-f2cfece5c802"
/dev/sda: UUID="2d9225e8-edc1-01fc-7d54-45fcbdcc8020" UUID_SUB="fec59176-0f3a-74d4-1947-32b508978749" LABEL="fangorn:0" TYPE="linux_raid_member"
/dev/sde: UUID="2d9225e8-edc1-01fc-7d54-45fcbdcc8020" UUID_SUB="efce71d0-3080-eecb-ce2f-8a166b2e4441" LABEL="fangorn:0" TYPE="linux_raid_member"
/dev/sdf: UUID="dddf84e3-2ec3-4156-8d18-5f1dce7be002" UUID_SUB="be5e9e9f-d627-2968-837c-9f656d2f62ba" LABEL="fangorn:1" TYPE="linux_raid_member"
/dev/sdg: UUID="dddf84e3-2ec3-4156-8d18-5f1dce7be002" UUID_SUB="1e73b358-a0c8-1c2d-34bd-8663e7906e6f" LABEL="fangorn:1" TYPE="linux_raid_member"
/dev/sdh1: UUID="6588304d-6098-4f80-836e-0e4832e2de8f" TYPE="ext4" PARTUUID="000533fc-01"
/dev/md0: UUID="7Nyd6C-oG50-b3jJ-aGkL-feIE-pAFc-5uM7vy" TYPE="LVM2_member"
/dev/md1: UUID="MtJAdS-Jdbn-2MR7-6evR-XCvL-wEm5-PUkg8p" TYPE="LVM2_member"
/dev/mapper/fg00-Data: LABEL="data" UUID="a26b7a38-d24f-4d28-ab8d-89233db95be6" TYPE="ext4"

PROMPT> mdadm -Es 
ARRAY /dev/md/1  metadata=1.2 UUID=dddf84e3:2ec34156:8d185f1d:ce7be002 name=fangorn:1
ARRAY /dev/md/0  metadata=1.2 UUID=2d9225e8:edc101fc:7d5445fc:bdcc8020 name=fangorn:0

이상한:/dev/md/0및 파일 은 없지만 및 /dev/md/1파일만 있습니다./dev/md0/dev/md1

PROMPT> mdadm --detail /dev/md[01]
/dev/md0:
           Version : 1.2
     Creation Time : Wed Oct 16 16:51:48 2019
        Raid Level : raid1
        Array Size : 3906886464 (3725.90 GiB 4000.65 GB)
     Used Dev Size : 3906886464 (3725.90 GiB 4000.65 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Wed Oct 16 16:57:03 2019
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

              Name : fangorn:0  (local to host fangorn)
              UUID : 2d9225e8:edc101fc:7d5445fc:bdcc8020
            Events : 2

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       1       8       64        1      active sync   /dev/sde
/dev/md1:
           Version : 1.2
     Creation Time : Wed Oct 16 16:51:56 2019
        Raid Level : raid1
        Array Size : 1953382464 (1862.89 GiB 2000.26 GB)
     Used Dev Size : 1953382464 (1862.89 GiB 2000.26 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Wed Oct 16 16:51:56 2019
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

              Name : fangorn:1  (local to host fangorn)
              UUID : dddf84e3:2ec34156:8d185f1d:ce7be002
            Events : 1

    Number   Major   Minor   RaidDevice State
       0       8       80        0      active sync   /dev/sdf
       1       8       96        1      active sync   /dev/sdg

이 두 개의 RAID1 어레이 위에 볼륨 그룹을 만들어 /data마운트 로 사용하는 하나의 단일 파티션에 함께 붙였습니다.

문제

재부팅할 때마다 RAID가 손실됩니다. 어레이에는 단일 흔적이 남아 있지 않습니다.

응, 수정했어/etc/mdadm/mdadm.conf

PROMPT> cat /etc/mdadm/mdadm.conf 
# mdadm.conf
#
# !NB! Run update-initramfs -u after updating this file.
# !NB! This will ensure that initramfs has an uptodate copy.
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers
DEVICE /dev/sda /dev/sde /dev/sdf /dev/sdg

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR m++++@++++++.++

# definitions of existing MD arrays

#ARRAY /dev/md1 metadata=1.2 name=fangorn:1 UUID=7068062b:a1a9265e:a7b5dc00:586d9f1b
#ARRAY /dev/md0 metadata=1.2 name=fangorn:0 UUID=9ab9aecd:cdfd3fe8:04587007:892edf3e
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.2 name=fangorn:0 UUID=7368baaf:9b08df19:d9362975:bf70eb1f devices=/dev/sda,/dev/sde
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 name=fangorn:1 UUID=dc218d09:18f63682:78b5ab94:6aa53459 devices=/dev/sdf,/dev/sdg

응, 내가 발행했어update-initramfs -u

데이터를 다시 가져오는 유일한 방법은 재부팅할 때마다 어레이를 다시 만드는 것입니다.

mdadm --create /dev/md0 --assume-clean --level=raid1 --verbose --raid-devices=2 /dev/sda /dev/sde
mdadm --create /dev/md1 --assume-clean --level=raid1 --verbose --raid-devices=2 /dev/sdf /dev/sdg
  • --assume-clean스위치를 주목해라
  • LVM은 즉시 자체적으로 다시 생성되며 마운트될 수 있습니다.
  • 데이터는 손실되지 않습니다.

하지만 재부팅 시 시스템이 어레이를 재조립하도록 하려면 어떻게 해야 합니까?

디스크에는 이미 꽤 많은 데이터가 있으므로 데이터 손실 없이 그렇게 할 수 있는 방법이 없다면 기본 하드웨어를 다시 분할하고 싶지 않습니다.

어레이와 LVM을 실행하지 않고도 데이터에 액세스할 수 있습니까?

추가 정보

  • 2019-10-22 추가됨

재부팅 직후 - 즉 재조립이 실패하고 단일 사용자 모드에 있는 경우 - mdadm에서 다음 출력을 얻습니다( mdadm.conf도움이 될지 확인하기 위해 삭제했지만 도움이 되지 않았습니다).

PROMPT> mdadm --assemble --scan -v 
mdadm: looking for devices for further assembly
mdadm: cannot open device /dev/sr0: No medium found
mdadm: no recogniseable superblock on /dev/sdh1
mdadm: Cannot assemble mbr metadata on /dev/sdh
mdadm: Cannot assemble mbr metadata on /dev/sdg
mdadm: Cannot assemble mbr metadata on /dev/sdf
mdadm: Cannot assemble mbr metadata on /dev/sde
mdadm: Cannot assemble mbr metadata on /dev/sda
mdadm: no recogniseable superblock on /dev/nvme0n1p3
mdadm: no recogniseable superblock on /dev/nvme0n1p2
mdadm: Cannot assemble mbr metadata on /dev/nvme0n1p1
mdadm: Cannot assemble mbr metadata on /dev/nvme0n1
mdadm: No arrays found in config file or automatically

그 후 위에서 설명한 대로 배열을 다시 만들고 다음과 같은 결과를 얻었습니다.

PROMPT> mdadm --create /dev/md0 --assume-clean --level=raid1 --verbose --raid-devices=2 /dev/sda /dev/sde
mdadm: partition table exists on /dev/sda
mdadm: partition table exists on /dev/sda but will be lost or
       meaningless after creating array
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: partition table exists on /dev/sde
mdadm: partition table exists on /dev/sde but will be lost or
       meaningless after creating array
mdadm: size set to 3906886464K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array? 
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

PROMPT> mdadm --create /dev/md1 --assume-clean --level=raid1 --verbose --raid-devices=2 /dev/sdf /dev/sdg
mdadm: partition table exists on /dev/sdf
mdadm: partition table exists on /dev/sdf but will be lost or
       meaningless after creating array
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: partition table exists on /dev/sdg
mdadm: partition table exists on /dev/sdg but will be lost or
       meaningless after creating array
mdadm: size set to 1953382464K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array?
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.

lsblk나중에 또 다른 작업을 수행했습니다 .

PROMPT>  lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
NAME            SIZE FSTYPE            TYPE  MOUNTPOINT
sda             3,7T linux_raid_member disk  
└─md0           3,7T LVM2_member       raid1 
  └─fg00-Data   5,5T ext4              lvm   /data
sde             3,7T linux_raid_member disk  
└─md0           3,7T LVM2_member       raid1 
  └─fg00-Data   5,5T ext4              lvm   /data
sdf             1,8T linux_raid_member disk  
└─md1           1,8T LVM2_member       raid1 
  └─fg00-Data   5,5T ext4              lvm   /data
sdg             1,8T linux_raid_member disk  
└─md1           1,8T LVM2_member       raid1 
  └─fg00-Data   5,5T ext4              lvm   /data
sdh           119,2G                   disk  
└─sdh1        119,2G ext4              part  /home
sr0            1024M                   rom   
nvme0n1         477G                   disk  
├─nvme0n1p1     300M vfat              part  /boot/efi
├─nvme0n1p2   442,1G ext4              part  /
└─nvme0n1p3    34,6G swap              part  [SWAP]

누군가가 이해할 수 있는 힌트인가요?

PROMPT> fdisk -l

The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sda: 3,65 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: ST4000DM004-2CV1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 513C284A-5CC0-4888-8AD0-83C4291B3D78


The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sde: 3,65 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: ST4000DM004-2CV1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 437D10E3-E679-4062-9321-E8EE1A1AA2F5


The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdf: 1,84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000DL003-9VT1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: E07D5DB8-7253-45DE-92C1-255B7F3E56C8


The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdg: 1,84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: Hitachi HDS5C302
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: E07D5DB8-7253-45DE-92C1-255B7F3E56C8

Disk /dev/md0: 3,65 TiB, 4000651739136 bytes, 7813772928 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/md1: 1,84 TiB, 2000263643136 bytes, 3906764928 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fg00-Data: 5,47 TiB, 6000908173312 bytes, 11720523776 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

또 다른 정보

PROMPT> gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.4

Caution! After loading partitions, the CRC doesn't check out!
Warning! Main partition table CRC mismatch! Loaded backup partition table
instead of main partition table!

Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: OK
Main partition table: ERROR
Backup partition table: OK

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

답변1

저는 Martin L. 솔루션의 또 다른 변형을 제시하고 싶습니다. 시스템이 작동하는 동안 새 어레이로의 데이터 마이그레이션이 투명하게 수행될 수 있기 때문에 가동 중지 시간이 훨씬 줄어든다는 점에서 다릅니다. 마이그레이션 중에는 디스크 성능 저하가 발생합니다.

제안된 대로 수행그의 대답에새로운 VG를 만들자고 제안하는 곳까지.

새로운 VG를 생성하지 마십시오. 새로 생성된 어레이에 새 PV를 생성하고 다음 PV를 사용하여 기존 VG를 확장합니다 vgextend fg00 /dev/md-NEW.

그런 다음 pvmove /dev/md-OLD. 이는 파일 시스템이 마운트되어 액세스되는 동안에도 수행될 수 있습니다. 시간이 오래 걸리겠지만 결국에는 완료됩니다. SSH 세션이 닫히면 중단되지 않고 5초마다 진행 상황이 표시되는지 확인하기 위해 screen, 그리고 verbosely: 내에서 이것을 실행했습니다 .screen pvmove -vi5 /dev/md-OLD

이를 수행하기 위해 새 PV에 PE가 충분하지 않은 경우가 있을 수 있습니다. 이제 전체 드라이브 대신 파티션을 사용하기 때문에 사용 가능한 공간과 배열 크기가 약간 더 작아졌습니다. 그렇다면 LV를 1개 줄여야 합니다. 예를 들어 FS를 마운트 해제하고 를 사용하여 resize2fsLV 크기를 줄입니다. 시간이 더 오래 걸리며, 바쁜 파일 시스템을 파일별로 복사하는 것보다 여전히 빠릅니다.

기존 PV가 비어 있으면(pvmove 완료) VG에서 이를 제거하고 PV 레이블을 제거한 후 기존 어레이를 제거합니다. 현재 사용하지 않는 드라이브를 삭제하고 파티션을 나눈 후 실행 중인 어레이에 추가하세요. 어레이 재동기화도 백그라운드에서 수행되며 완료될 때까지 디스크 성능이 저하됩니다.

mdadam --examine --scan >> /etc/mdadm/mdadm.conf이제 부팅 문제 를 해결하는 것을 잊지 마세요 update-initramfs.

답변2

@nh2는 쉽지만위험할 수도 있다그의 대답에 대한 해결책파티션을 사용하여 mdadm 배열을 생성하거나 전체 디스크를 직접 생성하는 것의 차이점은 무엇입니까?

그런데 이런 일이 발생하더라도 데이터는 손실되지 않습니다.아마도 sgdisk --zap장치만 사용한 다음 예를 들어 RAID를 다시 생성 할 수 있습니다 mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdc /dev/sdd(mdadm은 이미 과거 데이터를 감지했다고 알려주고 해당 데이터를 계속 재사용할 것인지 묻습니다). 이 작업을 여러 번 시도했고 효과가 있었지만 여전히 수행하기 전에 백업을 수행하는 것이 좋습니다.

오랜 연구 끝에 해결책을 찾았습니다.

내가 한 일은 다음과 같습니다.

먼저 상태 정보

PROMPT> df -h
Dateisystem           Größe Benutzt Verf. Verw% Eingehängt auf
/dev/mapper/fg00-Data  5,4T    1,5T  3,8T   28% /data

그런 다음 파티션을 마운트 해제하십시오.

PROMPT> umount /data

PROMPT> cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md1 : active raid1 sdg[1] sdf[0]
      1953382464 blocks super 1.2 [2/2] [UU]
      bitmap: 0/15 pages [0KB], 65536KB chunk

md0 : active raid1 sde[1] sda[0]
      3906886464 blocks super 1.2 [2/2] [UU]
      bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>

이제 두 어레이의 성능을 저하시킵니다.

PROMPT > mdadm --manage /dev/md0 --fail /dev/sde
mdadm: set /dev/sde faulty in /dev/md0

PROMPT > mdadm --manage /dev/md1 --fail /dev/sdg
mdadm: set /dev/sdg faulty in /dev/md1

PROMPT > cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md1 : active raid1 sdg[1](F) sdf[0]
      1953382464 blocks super 1.2 [2/1] [U_]
      bitmap: 0/15 pages [0KB], 65536KB chunk

md0 : active raid1 sde[1](F) sda[0]
      3906886464 blocks super 1.2 [2/1] [U_]
      bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>

어레이에서 디스크 제거

PROMPT > mdadm --manage /dev/md0 --remove /dev/sde 
mdadm: hot removed /dev/sde from /dev/md0
PROMPT > mdadm --manage /dev/md1 --remove /dev/sdg
mdadm: hot removed /dev/sdg from /dev/md1

PROMPT > cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md1 : active raid1 sdf[0]
      1953382464 blocks super 1.2 [2/1] [U_]
      bitmap: 0/15 pages [0KB], 65536KB chunk

md0 : active raid1 sda[0]
      3906886464 blocks super 1.2 [2/1] [U_]
      bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>

이제 /dev/sde/dev/sdg(재)분할이 자유롭게 가능합니다.

  • /dev/sde그래서 제안된 대로 /dev/sdg사용 가능한 공간보다 몇 MB 더 작은 새 파티션을 만들었습니다 .
  • 하나의 활성 디스크와 하나의 "누락" 디스크가 있는 새로운 2-디스크 RAID1 어레이 생성
  • 새로운 어레이를 물리 볼륨으로 사용하여 새로운 LVM 볼륨 그룹을 구축했습니다.
  • 그 위에 논리 볼륨을 생성했습니다(이전 볼륨과 동일한 크기에서 파티션을 생성할 때 손실된 몇 MB를 뺀 크기).
  • 이전 LV의 모든 데이터를 새 LV로 복사했습니다.
  • 이전 RAID를 파괴하고 디스크 파티션을 새 RAID에 추가했습니다.

여기 새로운 상태가 있습니다

PROMPT > lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
NAME              SIZE FSTYPE            TYPE  MOUNTPOINT
sda               3,7T                   disk  
└─sda1            3,7T linux_raid_member part  
  └─md2           3,7T LVM2_member       raid1 
    └─fg01-Data   5,5T ext4              lvm   /data
sde               3,7T                   disk  
└─sde1            3,7T linux_raid_member part  
  └─md2           3,7T LVM2_member       raid1 
    └─fg01-Data   5,5T ext4              lvm   /data
sdf               1,8T                   disk  
└─sdf1            1,8T linux_raid_member part  
  └─md3           1,8T LVM2_member       raid1 
    └─fg01-Data   5,5T ext4              lvm   /data
sdg               1,8T                   disk  
└─sdg1            1,8T linux_raid_member part  
  └─md3           1,8T LVM2_member       raid1 
    └─fg01-Data   5,5T ext4              lvm   /data
sdh             119,2G                   disk  
└─sdh1          119,2G ext4              part  /home
sr0              1024M                   rom   
nvme0n1           477G                   disk  
├─nvme0n1p1       300M vfat              part  /boot/efi
├─nvme0n1p2     442,1G ext4              part  /
└─nvme0n1p3      34,6G swap              part  [SWAP]

PROMPT > cat /proc/mdstat 
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md3 : active raid1 sdf1[1] sdg1[0]
      1953381376 blocks super 1.2 [2/1] [U_]
      [==>..................]  recovery = 10.0% (196493504/1953381376) finish=224.9min speed=130146K/sec
      bitmap: 0/15 pages [0KB], 65536KB chunk

md2 : active raid1 sda1[1] sde1[0]
      3906884608 blocks super 1.2 [2/1] [U_]
      [=>...................]  recovery =  6.7% (263818176/3906884608) finish=429.0min speed=141512K/sec
      bitmap: 2/30 pages [8KB], 65536KB chunk

unused devices: <none>

관련 정보