카프카 클러스터 구성을 위해 카프카 설치 영역과 데이터/로그 들이 모이는 영역을 분리해주는 작업을 하려고 한다.
계정 생성 등의 작업도 포함되어 있지만 주로 Volume Mount 쪽에 초점이 맞춰져 있다.
먼저 PV를 생성하고 VG안에서 LV를 나누는 순서로 구성한다.
# 현재 Mount 된 Disk 목록 조회
g_cloud@kaf-com-dev-msq1:/$ sudo fdisk -l
Disk /dev/loop0: 55.53 MiB, 58212352 bytes, 113696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop1: 61.92 MiB, 64901120 bytes, 126760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop2: 294.1 MiB, 308289536 bytes, 602128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop3: 43.64 MiB, 45748224 bytes, 89352 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/loop4: 67.83 MiB, 71106560 bytes, 138880 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: PersistentDisk
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/sda: 15 GiB, 16106127360 bytes, 31457280 sectors
Disk model: PersistentDisk
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: 23A58227-04F8-4BD6-B523-C88A9A2DAB17
Device Start End Sectors Size Type
/dev/sda1 227328 31457246 31229919 14.9G Linux filesystem
/dev/sda14 2048 10239 8192 4M BIOS boot
/dev/sda15 10240 227327 217088 106M EFI System
Partition table entries are not in disk order.
# 30GB 짜리 /dev/sdb 디스크에 pv를 만들어준다.
g_cloud@kaf-com-dev-msq1:/$ sudo pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
# pv를 조회
g_cloud@kaf-com-dev-msq1:/$ sudo pvscan
PV /dev/sdb lvm2 [30.00 GiB]
Total: 1 [30.00 GiB] / in use: 0 [0 ] / in no VG: 1 [30.00 GiB]
# 만들어진 pv안에 kafka 라는 vg를 생성
g_cloud@kaf-com-dev-msq1:/$ sudo vgcreate kafka /dev/sdb
Volume group "kafka" successfully created
# vg 조회
g_cloud@kaf-com-dev-msq1:/$ sudo vgscan
Found volume group "kafka" using metadata type lvm2
# vg 상세조회
g_cloud@kaf-com-dev-msq1:/$ sudo vgdisplay
--- Volume group ---
VG Name kafka
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size <30.00 GiB
PE Size 4.00 MiB
Total PE 7679
Alloc PE / Size 0 / 0
Free PE / Size 7679 / <30.00 GiB
VG UUID moBMhn-YsCD-hq4f-Xf2I-njxW-vk9a-7FmlCT
# kafka vg의 30GB 용량중 5GB를 install 라는 이름의 lv를 만들어서 할당한다.
g_cloud@kaf-com-dev-msq1:/$ sudo lvcreate -L 5GB -n install kafka
Logical volume "install" created.
# kafka vg의 30GB 용량중 나머지 100%를 datalog 라는 이름의 lv를 만들어서 할당한다.
g_cloud@kaf-com-dev-msq1:/$ sudo lvcreate -l 100%FREE -n datalog kafka
Logical volume "datalog" created.
# 만들어진 lv들 조회
g_cloud@kaf-com-dev-msq1:/$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/kafka/install
LV Name install
VG Name kafka
LV UUID jYGHso-OaAD-aHki-UMcr-dF8R-pO5p-vZ02KT
LV Write Access read/write
LV Creation host, time kaf-com-dev-msq1, 2022-05-25 07:08:52 +0000
LV Status available
# open 0
LV Size 5.00 GiB
Current LE 1280
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/kafka/datalog
LV Name datalog
VG Name kafka
LV UUID YY1p3e-AhIt-cdHd-T4xy-DEBF-IPHO-RE5fkc
LV Write Access read/write
LV Creation host, time kaf-com-dev-msq1, 2022-05-25 07:09:34 +0000
LV Status available
# open 0
LV Size <25.00 GiB
Current LE 6399
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
# 만들어진 lv들을 xfs 파일시스템으로 포맷해준다.
g_cloud@kaf-com-dev-msq1:/$ sudo mkfs.xfs /dev/kafka/install
meta-data=/dev/kafka/install isize=512 agcount=4, agsize=327680 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
g_cloud@kaf-com-dev-msq1:/$ sudo mkfs.xfs /dev/kafka/datalog
meta-data=/dev/kafka/datalog isize=512 agcount=4, agsize=1638144 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=6552576, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=3199, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# block id 확인, 방금 만든 두 lv의 UUID와 TYPE 확인가능
g_cloud@kaf-com-dev-msq1:/$ sudo blkid
/dev/sda1: LABEL="cloudimg-rootfs" UUID="91842ad1-ec38-45c0-bf13-d346230ada21" TYPE="ext4" PARTUUID="0ad9b47d-8aac-4376-896f-3c4a6893f6e5"
/dev/sda15: LABEL_FATBOOT="UEFI" LABEL="UEFI" UUID="EE13-815A" TYPE="vfat" PARTUUID="8f067e10-a28e-4dcd-9285-f1ad4aa10fb8"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/sdb: UUID="YuFxhe-B101-Vj7G-pY0G-7h8j-MQGg-gyT3lR" TYPE="LVM2_member"
/dev/sda14: PARTUUID="8b0decd8-4dde-44ed-92a7-27ed6bed7112"
/dev/mapper/kafka-install: UUID="8ee78e23-f8af-4a8e-91e2-2006199991b8" TYPE="xfs"
/dev/mapper/kafka-datalog: UUID="4f7f0fc3-65c7-4032-ba79-d14d9ccdbbec" TYPE="xfs"
# 만든 두 lv와 mount 시킬 디렉토리 2개를 각각 만들어 준다.
g_cloud@kaf-com-dev-msq1:/$ sudo mkdir /datalog
g_cloud@kaf-com-dev-msq1:/$ sudo mkdir /kafka
# fstab 파일을 수정, UUID와 마운트할 디렉토리 등의 정보를 추가
g_cloud@kaf-com-dev-msq1:/$ sudo vi /etc/fstab
# 모두 마운트 시키고, 결과 확인
g_cloud@kaf-com-dev-msq1:/$ sudo mount -a
g_cloud@kaf-com-dev-msq1:/$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 1.8G 13G 13% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 393M 944K 392M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/loop0 56M 56M 0 100% /snap/core18/2344
/dev/loop1 62M 62M 0 100% /snap/core20/1405
/dev/loop2 295M 295M 0 100% /snap/google-cloud-sdk/235
/dev/loop3 44M 44M 0 100% /snap/snapd/15177
/dev/loop4 68M 68M 0 100% /snap/lxd/22753
/dev/sda15 105M 5.2M 100M 5% /boot/efi
tmpfs 393M 0 393M 0% /run/user/1002
/dev/mapper/kafka-install 5.0G 68M 5.0G 2% /kafka
/dev/mapper/kafka-datalog 25G 211M 25G 1% /datalog
# kafka user 추가, home 디렉토리 /kafka로 설정, passwd 설정
g_cloud@kaf-com-dev-msq1:/$ sudo useradd -d /kafka -s /bin/bash kafka
g_cloud@kaf-com-dev-msq1:/$ sudo cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
sshd:x:109:65534::/run/sshd:/usr/sbin/nologin
landscape:x:110:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:111:1::/var/cache/pollinate:/bin/false
_chrony:x:112:119:Chrony daemon,,,:/var/lib/chrony:/usr/sbin/nologin
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash
g-cloud:x:1001:1002::/home/g-cloud:/bin/bash
lxd:x:998:100::/var/snap/lxd/common/lxd:/bin/false
g_cloud:x:1002:1003::/home/g_cloud:/bin/bash
kafka:x:1003:1004::/kafka:/bin/bash
g_cloud@kaf-com-dev-msq1:/$ sudo passwd kafka
New password:
Retype new password:
passwd: password updated successfully
g_cloud@kaf-com-dev-msq1:/$ ls -al
total 72
drwxr-xr-x 21 root root 4096 May 25 07:12 .
drwxr-xr-x 21 root root 4096 May 25 07:12 ..
lrwxrwxrwx 1 root root 7 Apr 19 19:32 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Apr 19 19:37 boot
drwxr-xr-x 2 root root 6 May 25 07:10 datalog
drwxr-xr-x 18 root root 3940 May 25 07:09 dev
drwxr-xr-x 96 root root 4096 May 25 07:16 etc
drwxr-xr-x 5 root root 4096 May 25 06:07 home
drwxr-xr-x 2 root root 6 May 25 07:10 kafka
lrwxrwxrwx 1 root root 7 Apr 19 19:32 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Apr 19 19:32 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Apr 19 19:32 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Apr 19 19:32 libx32 -> usr/libx32
drwx------ 2 root root 16384 Apr 19 19:34 lost+found
drwxr-xr-x 2 root root 4096 Apr 19 19:32 media
drwxr-xr-x 2 root root 4096 Apr 19 19:32 mnt
drwxr-xr-x 2 root root 4096 Apr 19 19:32 opt
dr-xr-xr-x 183 root root 0 May 25 05:57 proc
drwx------ 4 root root 4096 May 25 07:14 root
drwxr-xr-x 24 root root 820 May 25 06:31 run
lrwxrwxrwx 1 root root 8 Apr 19 19:32 sbin -> usr/sbin
drwxr-xr-x 8 root root 4096 Apr 19 19:36 snap
drwxr-xr-x 2 root root 4096 Apr 19 19:32 srv
dr-xr-xr-x 13 root root 0 May 25 05:57 sys
drwxrwxrwt 12 root root 4096 May 25 06:37 tmp
drwxr-xr-x 14 root root 4096 Apr 19 19:33 usr
drwxr-xr-x 13 root root 4096 Apr 19 19:34 var
# 마운트 시킨 디렉토리들 권한을 root에서 kafka 계정으로 변경
g_cloud@kaf-com-dev-msq1:/$ sudo chown -R kafka:kafka /datalog
g_cloud@kaf-com-dev-msq1:/$ sudo chown -R kafka:kafka /kafka/
g_cloud@kaf-com-dev-msq1:/$ ls -al
total 72
drwxr-xr-x 21 root root 4096 May 25 07:12 .
drwxr-xr-x 21 root root 4096 May 25 07:12 ..
lrwxrwxrwx 1 root root 7 Apr 19 19:32 bin -> usr/bin
drwxr-xr-x 4 root root 4096 Apr 19 19:37 boot
drwxr-xr-x 2 kafka kafka 6 May 25 07:10 datalog
drwxr-xr-x 18 root root 3940 May 25 07:09 dev
drwxr-xr-x 96 root root 4096 May 25 07:16 etc
drwxr-xr-x 5 root root 4096 May 25 06:07 home
drwxr-xr-x 2 kafka kafka 6 May 25 07:10 kafka
lrwxrwxrwx 1 root root 7 Apr 19 19:32 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Apr 19 19:32 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Apr 19 19:32 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Apr 19 19:32 libx32 -> usr/libx32
drwx------ 2 root root 16384 Apr 19 19:34 lost+found
drwxr-xr-x 2 root root 4096 Apr 19 19:32 media
drwxr-xr-x 2 root root 4096 Apr 19 19:32 mnt
drwxr-xr-x 2 root root 4096 Apr 19 19:32 opt
dr-xr-xr-x 183 root root 0 May 25 05:57 proc
drwx------ 4 root root 4096 May 25 07:14 root
drwxr-xr-x 24 root root 820 May 25 06:31 run
lrwxrwxrwx 1 root root 8 Apr 19 19:32 sbin -> usr/sbin
drwxr-xr-x 8 root root 4096 Apr 19 19:36 snap
drwxr-xr-x 2 root root 4096 Apr 19 19:32 srv
dr-xr-xr-x 13 root root 0 May 25 05:57 sys
drwxrwxrwt 12 root root 4096 May 25 06:37 tmp
drwxr-xr-x 14 root root 4096 Apr 19 19:33 usr
drwxr-xr-x 13 root root 4096 Apr 19 19:34 var
g_cloud@kaf-com-dev-msq1:/$ su - kafka
Password:
kafka@kaf-com-dev-msq1:~$ pwd
/kafka
'IT > Linux' 카테고리의 다른 글
LVM을 사용하여 CentOS8에 파일시스템을 추가하고 삭제하기. (0) | 2024.04.27 |
---|---|
GCP 콘솔에서 Disk 크기를 확장 한 뒤, LVM을 사용하여 리눅스 볼륨 확장 할당하기. (1) | 2022.10.04 |
[Linux] 리눅스에서 유저 생성 후 bash shell에서 사용자@호스트가 보이지 않을 때. (0) | 2022.07.20 |
[Linux] pvcreate 명령어를 찾을 수 없을 때. (0) | 2022.07.20 |
[Linux] SSH Key 등록을 통해 Server에 Password 없이 접속하기. (1) | 2022.02.17 |