하드디스크관리-RAID 개념과 종류
2024. 11. 16. 10:29ㆍb정리/이것이 리눅스다-우분투-3판
728x90
반응형
https://www.youtube.com/watch?v=KrnePiEqX9A&list=PLqTUMsvO70nnPQ42mtOKCgzlXeIy8GB0U&index=34
Linear RAID와 RAID 0
Linear RAID | RAID 0 |
최소 2개의 하드디스크 필요 | 최소 2개의 하드디스크 필요 |
2개 이상의 하드디스크를 1개의 볼륨으로 사용 | 모든 디스크에 동시에 저장됨 |
앞 디스크부터 차례로 저장 | 100% 공간효율성 |
100% 공간효율성 | 신뢰성 낮음 |
- | 빠흔 성능 요구, 단 전부 잃어버려도 큰 문제가 되지 않는 자료가 적당 |
RAID 1
![]() |
![]() |
RAID 5
- RAID 1의 데이터의 안전서 + RAID 0처럼 공간 효율성
- 최소한 3개 이상의 하드디스크
- 오류가 발생할 때는 패리티를 이용해서 데이터를 복구
RAID 6
- RAID 6 방식은 RAID 5 방식이 개선된 것
- 공간 효율은 RAID 5보다 약간 떨어지지만, 2개의 디스크가 동시에 고장이 나도 데이터에는 이상이 없도록 하는 방식
- 최소 4개의 디스크 필요
- 공간 효율 - RAID 1 <<< RAID 6 < RAID 5
- 성능(속도)은 5에 비해 약간 떨어짐
RAID 1+0
신뢰성과 성능이 동시에 뛰어난 방법
RIAD 연습
디스크 7개 준비 및 파티션, 디스크 설정
root@ServerA:~# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh
root@ServerA:~# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.39.3).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS (MBR) disklabel with disk identifier 0x01fa6c14.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-2097151, default 2097151):
Created a new partition 1 of type 'Linux' and of size 1023 MiB.
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): L
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.
Command (m for help): p
Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors
Disk model: VMware Virtual S
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: dos
Disk identifier: 0x01fa6c14
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2097151 2095104 1023M fd Linux raid autodetect
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
- 7개 디스크 전부 똑같이 진행
apt -y install mdadm
https://www.youtube.com/watch?v=BpTeIOWulTM&list=PLqTUMsvO70nnPQ42mtOKCgzlXeIy8GB0U&index=36
RAID 0 구축
root@ServerA:~# fdisk -l /dev/sdb
Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 sectors
Disk model: VMware Virtual S
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: dos
Disk identifier: 0x01fa6c14
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2097151 2095104 1023M fd Linux raid autodetect
root@ServerA:~# fdisk -l /dev/sdc
Disk /dev/sdc: 1 GiB, 1073741824 bytes, 2097152 sectors
Disk model: VMware Virtual S
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: dos
Disk identifier: 0x63717f36
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 2097151 2095104 1023M fd Linux raid autodetect
## 논리 볼륨 작성
root@ServerA:~# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
root@ServerA:~# mdadm --detail --scan
ARRAY /dev/md0 metadata=1.2 UUID=6c621ed1:24483e16:b5e7895b:612148ff
## 파일시스템 생성
root@ServerA:~# mkfs.ext4 /dev/md0
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 522752 4k blocks and 130816 inodes
Filesystem UUID: c2af407b-cfd0-4c7e-89b3-b21c77393390
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
## 마운트 및 마운트 확인
root@ServerA:~# mkdir /raid0
root@ServerA:~# mount /dev/md0 /raid0/
root@ServerA:~# df
파일 시스템 1K-블록 사용 가용 사용% 마운트위치
tmpfs 396104 1956 394148 1% /run
/dev/sda2 81984920 10650556 67123832 14% /
tmpfs 1980500 0 1980500 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 396100 100 396000 1% /run/user/0
/dev/md0 2019240 24 1898284 1% /raid0
## /etc/fstab 등록
vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/2ed4635c-10fa-4383-b0f1-c596a59bc8c5 / ext4 defaults 0 1
/swap.img none swap sw 0 0
/dev/md0 /raid0 ext4 defaults 0 0
## 적용
systemctl daemon-reload
root@ServerA:~# mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Nov 15 21:03:07 2024
Raid Level : raid0
Array Size : 2091008 (2042.00 MiB 2141.19 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Nov 15 21:03:07 2024
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Layout : original
Chunk Size : 512K
Consistency Policy : none
Name : ServerA:0 (local to host ServerA)
UUID : 6c621ed1:24483e16:b5e7895b:612148ff
Events : 0
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 33 1 active sync /dev/sdc1
RAID 1 구성
## RAID 1 구성
root@ServerA:~# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdd1 /dev/sde1
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
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
## 파일시스템 설정
root@ServerA:~# mkfs.ext4 /dev/md1
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 261632 4k blocks and 65408 inodes
Filesystem UUID: d074c087-78ce-457d-8a59-be164236e01b
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
## 마운트 및 확인
root@ServerA:~# mkdir /raid1
root@ServerA:~# mount /dev/md1 /raid1
root@ServerA:~# df
파일 시스템 1K-블록 사용 가용 사용% 마운트위치
tmpfs 396104 1964 394140 1% /run
/dev/sda2 81984920 10650564 67123824 14% /
tmpfs 1980500 0 1980500 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 396100 100 396000 1% /run/user/0
/dev/md0 2019240 24 1898284 1% /raid0
/dev/md1 1011148 24 942416 1% /raid1
### /etc/fstab 설정
root@ServerA:~# vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during curtin installation
/dev/disk/by-uuid/2ed4635c-10fa-4383-b0f1-c596a59bc8c5 / ext4 defaults 0 1
/swap.img none swap sw 0 0
/dev/md0 /raid0 ext4 defaults 0 0
/dev/md1 /raid1 ext4 defaults 0 0
# 적용
root@ServerA:~# systemctl daemon-reload
## 확인
root@ServerA:~# mdadm --detail /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Fri Nov 15 21:09:33 2024
Raid Level : raid1
Array Size : 1046528 (1022.00 MiB 1071.64 MB)
Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Nov 15 21:10:34 2024
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : ServerA:1 (local to host ServerA)
UUID : ff0fd3fa:55169fb6:8250a4d7:293f7ca6
Events : 17
Number Major Minor RaidDevice State
0 8 49 0 active sync /dev/sdd1
1 8 65 1 active sync /dev/sde1
RAID 5 방식 구성
### raid 만들기
mdadm --create /dev/md5 --level=5 --raid-devices=3 /dev/sdf1 /dev/sdg1 /dev/sdh1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
### 파일 시스템 설정
mkfs.ext4 /dev/md5
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 522752 4k blocks and 130816 inodes
Filesystem UUID: 0f98b058-c510-421e-af73-6ea63afb48e3
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
### 마운트 및 설정 확인
root@ServerA:~# mkdir /raid5
root@ServerA:~# mount /dev/md5 /raid5
mount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.
root@ServerA:~# df
파일 시스템 1K-블록 사용 가용 사용% 마운트위치
tmpfs 396104 1972 394132 1% /run
/dev/sda2 81984920 10650572 67123816 14% /
tmpfs 1980500 0 1980500 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 396100 100 396000 1% /run/user/0
/dev/md0 2019240 24 1898284 1% /raid0
/dev/md1 1011148 24 942416 1% /raid1
/dev/md5 2019240 24 1898284 1% /raid5
root@ServerA:~# vi /etc/fstab
### 데몬 리로드
root@ServerA:~# systemctl daemon-reload
root@ServerA:~# mdadm --detail /dev/md5
/dev/md5:
Version : 1.2
Creation Time : Fri Nov 15 21:14:06 2024
Raid Level : raid5
Array Size : 2091008 (2042.00 MiB 2141.19 MB)
Used Dev Size : 1045504 (1021.00 MiB 1070.60 MB)
Raid Devices : 3
root@ServerA:~# mdadm --detail --scan
ARRAY /dev/md0 metadata=1.2 UUID=09cbe15c:72252115:303e81cc:e6e8340c
ARRAY /dev/md1 metadata=1.2 UUID=76611730:7f18e0cc:e79284a7:6e88dc40
ARRAY /dev/md5 metadata=1.2 UUID=39301aa1:1fe88d17:48ddf2e5:7ee34f14
root@ServerA:~# vi /etc/mdadm/mdadm.conf
root@ServerA:~# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-6.8.0-48-generic
reboot 후 확인
root@ServerA:~# df
파일 시스템 1K-블록 사용 가용 사용% 마운트위치
tmpfs 396104 1940 394164 1% /run
/dev/sda2 81984920 10656460 67117928 14% /
tmpfs 1980512 0 1980512 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
/dev/md0 2019240 24 1898284 1% /raid0
/dev/md1 1011148 24 942416 1% /raid1
/dev/md5 2019240 24 1898284 1% /raid5
tmpfs 396100 100 396000 1% /run/user/0
root@ServerA:~#
root@ServerA:~#
root@ServerA:~#
root@ServerA:~#
root@ServerA:~#
root@ServerA:~# ls -l /dev/md*
brw-rw---- 1 root disk 9, 0 11월 15 22:43 /dev/md0
brw-rw---- 1 root disk 9, 1 11월 15 22:43 /dev/md1
brw-rw---- 1 root disk 9, 5 11월 15 22:43 /dev/md5
장치 고장 대처
root@ServerA:~# mdadm --detail --scan
INACTIVE-ARRAY /dev/md5 metadata=1.2 UUID=39301aa1:1fe88d17:48ddf2e5:7ee34f14
INACTIVE-ARRAY /dev/md1 metadata=1.2 UUID=76611730:7f18e0cc:e79284a7:6e88dc40
INACTIVE-ARRAY /dev/md0 metadata=1.2 UUID=09cbe15c:72252115:303e81cc:e6e8340c
root@ServerA:~# mdadm --run /dev/md5
mdadm: started array /dev/md5
root@ServerA:~# mdadm --run /dev/md1
mdadm: started array /dev/md1
root@ServerA:~# mdadm --detail --scan
ARRAY /dev/md5 metadata=1.2 UUID=39301aa1:1fe88d17:48ddf2e5:7ee34f14
ARRAY /dev/md1 metadata=1.2 UUID=76611730:7f18e0cc:e79284a7:6e88dc40
INACTIVE-ARRAY /dev/md0 metadata=1.2 UUID=09cbe15c:72252115:303e81cc:e6e8340c
root@ServerA:~# mdadm --stop /dev/md0
mdadm: stopped /dev/md0
root@ServerA:~# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid0 devices=2 ctime=Fri Nov 15 22:36:10 2024
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
root@ServerA:~# mdadm /dev/md1 --add /dev/sde1
mdadm: added /dev/sde1
root@ServerA:~# mdadm /dev/md5 --add /dev/sdg1
mdadm: added /dev/sdg1
root@ServerA:~# mdadm --detail --scan
ARRAY /dev/md1 metadata=1.2 UUID=76611730:7f18e0cc:e79284a7:6e88dc40
ARRAY /dev/md5 metadata=1.2 UUID=39301aa1:1fe88d17:48ddf2e5:7ee34f14
ARRAY /dev/md0 metadata=1.2 UUID=83d323af:6c647c0e:d943db95:d99d8cf5
root@ServerA:~# vi /etc/mdadm/mdadm.conf
root@ServerA:~# vi /etc/fstab
root@ServerA:~# update-initramfs -u
반응형
'b정리 > 이것이 리눅스다-우분투-3판' 카테고리의 다른 글
웹서버-APM 설치, 운영/클라우드 저장 서비스 구축 (0) | 2024.11.20 |
---|---|
하드디스크관리2 (0) | 2024.11.20 |
하드디스크관리 (1) | 2024.11.15 |
하드디스크관리 (0) | 2024.11.15 |
필수개념과 명령어-마운트와 CD,DVD,USB 활용 (0) | 2024.11.13 |