![mdadm raid 6 배열 감소 오류로 인해 /dev/sda1에 대해 new_offset을 설정할 수 없습니다.](https://linux55.com/image/208349/mdadm%20raid%206%20%EB%B0%B0%EC%97%B4%20%EA%B0%90%EC%86%8C%20%EC%98%A4%EB%A5%98%EB%A1%9C%20%EC%9D%B8%ED%95%B4%20%2Fdev%2Fsda1%EC%97%90%20%EB%8C%80%ED%95%B4%20new_offset%EC%9D%84%20%EC%84%A4%EC%A0%95%ED%95%A0%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
mdadm raid6 배열의 크기를 10에서 8로 줄여 보았습니다.
그래서 나는 다음 단계를 따릅니다.
pi@raspbian-x64:~ $ sudo mdadm --grow /dev/md0 --raid-devices=8
mdadm: this change will decrease the size of the array.
use --grow --array-size first to truncate array.
e.g. mdadm --grow /dev/md0 --array-size 2928887808
pi@raspbian-x64:~ $ sudo mdadm --grow /dev/md0 --array-size 2928887808
pi@raspbian-x64:~ $ sudo mdadm --grow /dev/md0 --raid-devices=8
mdadm: Cannot set new_offset for /dev/sda1
mdadm이 /dev/sda1에 대해 new_offset을 설정할 수 없는 이유를 알고 계십니까?
내 배열의 세부 정보는 다음과 같습니다(명령 사용 후).
pi@raspbian-x64:~ $ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue May 11 07:47:04 2021
Raid Level : raid6
Array Size : 2928887808 (2793.21 GiB 2999.18 GB)
Used Dev Size : 488147968 (465.53 GiB 499.86 GB)
Raid Devices : 10
Total Devices : 8
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Mon Jul 18 02:18:12 2022
State : clean, degraded
Active Devices : 8
Working Devices : 8
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : bitmap
Name : pi1:0
UUID : 4314f81c:4b2f90a0:db6089d4:c5958ee0
Events : 147618
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
2 8 49 2 active sync /dev/sdd1
- 0 0 3 removed
10 8 65 4 active sync /dev/sde1
9 8 82 5 active sync /dev/sdf2
8 8 81 6 active sync /dev/sdf1
- 0 0 7 removed
7 8 2 8 active sync /dev/sda2
6 8 1 9 active sync /dev/sda1
현재 RAID 어레이에는 46%의 여유 공간이 있습니다. 따라서 배열을 8개 장치로 줄이는 것이 좋습니다.
업데이트 1:
장치 수를 10개에서 7개로 줄이고 싶습니다.
newSize = devSize * (totalWantedDeviceCount - raid6deviceIntegrityCount)
newSize = 488147968 * (7 - 2)
newSize = 2440739840 (instead of 3905183744)
그래서 RAID 배열 파일 시스템의 크기를 줄일 수 있었습니다.
sudo resize2fs /dev/md0 2440739840K
(나는 많은 버그를 수정해야 했다 sudo e2fsck -f /dev/md0 -y
)
다음으로 mdadm에서 RAID 배열의 크기를 줄였습니다.
sudo mdadm --grow /dev/md0 --array-size 2440739840
효율적인:
pi@raspbian-x64:~ $ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue May 11 07:47:04 2021
Raid Level : raid6
Array Size : 2440739840 (2327.67 GiB 2499.32 GB)
Used Dev Size : 488147968 (465.53 GiB 499.86 GB)
Raid Devices : 10
Total Devices : 10
Persistence : Superblock is persistent
Intent Bitmap : Internal
Update Time : Mon Aug 15 20:57:47 2022
State : clean
Active Devices : 10
Working Devices : 10
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : bitmap
Name : pi1:0
UUID : 4314f81c:4b2f90a0:db6089d4:c5958ee0
Events : 205009
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 33 1 active sync /dev/sdc1
2 8 81 2 active sync /dev/sdf1
5 8 129 3 active sync /dev/sdi1
10 8 113 4 active sync /dev/sdh1
11 8 49 5 active sync /dev/sdd1
8 8 97 6 active sync /dev/sdg1
4 8 17 7 active sync /dev/sdb1
7 8 66 8 active sync /dev/sde2
6 8 65 9 active sync /dev/sde1
3개의 장치를 제거하려고 시도했지만 동일한 오류가 발생했습니다.
pi@raspbian-x64:~ $ sudo mdadm --grow /dev/md0 --raid-devices=7
mdadm: Cannot set new_offset for /dev/sda1
업데이트 2:
배열 크기를 줄이지 못해서 없애고 처음부터 새 배열을 새로 만들어야 했는데...
업데이트 3:
Qbert-Pacman 트릭을 사용하여 RAID 배열의 크기를 줄이기 위해 실행하는 데 필요한 명령을 생성하는 데 도움이 되는 스크립트를 만들었습니다.github의 스크립트.
누구에게나 효과가 있는지 알려주세요.
답변1
이 정보가 도움이 되기를 바랍니다. 나는 raid4 어레이를 8개의 SSD 드라이브에서 4개의 SSD 드라이브로 줄이려고 할 때 문서화한 것과 동일한 단계를 따랐습니다.
ext4 파일 시스템 크기가 감소되었습니다. 2fs/파일 시스템 크기 조정 2929890816
mdadm raid4 배열의 크기가 감소되었습니다. mdadm -G /dev/md0 --배열 크기 2929890816
mdadm raid4 장치를 SSD 드라이브 8개에서 SSD 드라이브 4개로 줄이려고 시도했지만 동일한 오류가 발생했습니다(mdadm: /dev/sdX에 대해 new_offset을 설정할 수 없습니다.). mdadm -G /dev/md0 -l4 -n4
재구성 과정에서 임시 데이터를 저장하기 위해 백업 파일을 할당하는 추가 옵션을 추가하여 이 문제를 해결했습니다. 이전 명령은 mdadm raid4 축소 문제를 해결하는 다음 명령으로 대체되었습니다.
mdadm -G /dev/md0 -l4 -n4 --백업 파일/var/tmp/md0-backup
백업 파일이 생성되고 약 10752k를 사용하여 임시 데이터를 보관합니다. 백업 파일의 할당 및 사용을 확인하는 명령을 실행하면 다음과 같은 추가 출력이 나타납니다.
mdadm: 10752K의 중요 섹션을 백업해야 합니다.
이 정보가 향후 mdadm 장치 재구성 작업에 유용할 수 있기를 바랍니다.