일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 스트림셋이란?
- c++
- 정보처리기사
- 자바
- 파이썬
- 코딩
- 알고리즘
- mysql on docker
- 데이트
- docker
- python
- 도커
- 클라우드
- MySQL
- streamsets 강의
- elk stack
- 도커 mysql
- 도커 시작하기
- 앤서블 설치
- 백준
- C언어
- c
- nvidia docker
- 도커 elk
- 푸시푸시
- ansible install
- 데이터베이스
- 스트림셋
- java
- mysql docker
- Today
- Total
리그캣의 개발놀이터
lvm 사용 환경 디스크 용량 늘리기 본문
LVM (Logical Volume Manage)
논리적 서버에서 부족한 용량 확장하는 방법
터미널 접속 후 서버 용량 확인
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 50G 50G 20K 100% / devtmpfs 32G 0 32G 0% /dev tmpfs 32G 0 32G 0% /dev/shm tmpfs 32G 3.8G 28G 12% /run tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/sda1 1014M 179M 836M 18% /boot /dev/mapper/centos-home 245G 508M 245G 1% /home 10.231.227.140:/datalake01 536G 2.3G 534G 1% /nfs-hci-01 tmpfs 6.3G 12K 6.3G 1% /run/user/42 tmpfs 6.3G 0 6.3G 0% /run/user/0 tmpfs 6.3G 0 6.3G 0% /run/user/1000 |
늘어나기 전 disk 용량 확인 (늘어난 용량 확인하기 위함)
# fdisk /dev/sda
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 336.9 GB, 536870912000 bytes, 1048576000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 1048576 bytes Disk label type: dos Disk identifier: 0x000b5b4d
Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 629145599 313523200 8e Linux LVM
Command (m for help): q |
사용하시는 환경에 맞추어 disk 용량 추가(예 : vmware 디스크 용량 추가?)
터미널 재접속 후 root 권한 얻기
총 물리적 disk 용량 확인 (늘어난 용량 확인하기 위함)
[root@mesos04 ~]# fdisk /dev/sda
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 1048576 bytes Disk label type: dos Disk identifier: 0x000b5b4d
Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 629145599 313523200 8e Linux LVM
Command (m for help): q |
Pvscan을 통한 physical volume 및 lvm2 상태 확인
[root@mesos04 ~]# pvscan PV /dev/sda2 VG centos lvm2 [<299.00 GiB / 4.00 MiB free] Total: 1 [<299.00 GiB] / in use: 1 [<299.00 GiB] / in no VG: 0 [0 ] |
Lvdisplay 를 통한 용량을 늘릴 filesystem 확인
# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID Vd3916-46XL-iRfn-cAfI-f6Qt-rOD6-alkRXe LV Write Access read/write LV Creation host, time localhost.localdomain, 2019-05-10 10:14:54 +0900 LV Status available # open 2 LV Size <3.88 GiB Current LE 992 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
--- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID krmoBp-7Hos-i8am-LeBc-pcFH-Vw8F-ON0cRb LV Write Access read/write LV Creation host, time localhost.localdomain, 2019-05-10 10:14:55 +0900 LV Status available # open 1 LV Size <245.12 GiB Current LE 62750 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
--- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID TxWne9-cHgr-mpB8-4Xw2-fBd2-2cNe-sxf4Cr LV Write Access read/write LV Creation host, time localhost.localdomain, 2019-05-10 10:14:57 +0900 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 |
Fdisk 를 이용한 파티션 생성
# fdisk /dev/sda
The device presents a logical sector size that is smaller than the physical sector size. Aligning to a physical sector (or optimal I/O) size boundary is recommended, or performance may be impacted. Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 <- 파티션넘버!! First sector (629145600-1048575999, default 629145600): Using default value 629145600 Last sector, +sectors or +size{K,M,G} (629145600-1048575999, default 1048575999): Using default value 1048575999 Partition 3 of type Linux and of size 200 GiB is set
Command (m for help): p
Disk /dev/sda: 536.9 GB, 536870912000 bytes, 1048576000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 1048576 bytes Disk label type: dos Disk identifier: 0x000b5b4d
Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 629145599 313523200 8e Linux LVM /dev/sda3 629145600 1048575999 209715200 83 Linux
Command (m for help): t Partition number (1-3, default 3): 3 <-파티션 넘버 중요 Hex code (type L to list all codes): 8e <- lvm 사용한다는 말인듯? Changed type of partition 'Linux' to 'Linux LVM'
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. |
재부팅(기존프로세스 영향상태 확인 후 재부팅 바람.)
shutdown -r now
터미널 재접속
Pvscan (기존 physical volume scanning)
[root@mesos04 ~]# pvscan PV /dev/sda2 VG centos lvm2 [<299.00 GiB / 4.00 MiB free] Total: 1 [<299.00 GiB] / in use: 1 [<299.00 GiB] / in no VG: 0 [0 ] |
Pvcreate를 통한 물리적 볼륨 생성
# pvcreate /dev/sda3 <-파티션넘버 Physical volume "/dev/sda3" successfully created. |
Pvscan을 통한 용량 확인 (ex.200GB 새로 추가)
# pvscan PV /dev/sda2 VG centos lvm2 [<299.00 GiB / 4.00 MiB free] PV /dev/sda3 lvm2 [200.00 GiB] Total: 2 [<499.00 GiB] / in use: 1 [<299.00 GiB] / in no VG: 1 [200.00 GiB] |
볼륨그룹 확인(vgdisplay)
# vgdisplay --- Volume group --- VG Name centos |
볼륨 그룹 확장
# vgextend centos /dev/sda3 Volume group "centos" successfully extended |
볼륨그룹 크기 확인(vgdisplay)
# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size 498.99 GiB PE Size 4.00 MiB Total PE 127742 Alloc PE / Size 76543 / <299.00 GiB Free PE / Size 51199 / <200.00 GiB VG UUID aoN2d9-mvTm-1aoa-jV8n-cXJi-xedf-3MkzM7 |
물리적 파티션 용량 증가
# lvextend /dev/mapper/centos-root -l +100%FREE <- 저는 남은 용량을 다 할당시킨다고 한거에요!! Size of logical volume centos/root changed from 50.00 GiB (12801 extents) to 250.00 GiB (64000 extents). Logical volume centos/root successfully resized. |
리사이즈(아래와 같은 에러 발생시 파일시스템 구성확인해야함)
# resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock. |
아래부터는 위와 같은 에러 발생시 진행
Filesystem type 확인
# blkid /dev/mapper/centos-root /dev/mapper/centos-root: UUID="1d37744e-a249-4fcc-8271-2118d3d59ea9" TYPE="xfs" |
Xfs의 경우 아래와 같은 명령어 입력해야함
# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 65536000 |
용량 재확인
# df -h /dev/mapper/centos-root 250G 48G 203G 20% / devtmpfs 32G 0 32G 0% /dev tmpfs 32G 0 32G 0% /dev/shm tmpfs 32G 34M 32G 1% /run tmpfs 32G 0 32G 0% /sys/fs/cgroup /dev/sda1 1014M 179M 836M 18% /boot /dev/mapper/centos-home 245G 508M 245G 1% /home 10.231.227.140:/datalake01 536G 2.3G 534G 1% /nfs-hci-01 tmpfs 6.3G 0 6.3G 0% /run/user/1000 tmpfs 6.3G 12K 6.3G 1% /run/user/42 |
ㅎㅎ 문의사항있으면 댓글달아주세요~