3.5. etcd를 다른 디스크로 이동
etcd를 공유 디스크에서 별도의 디스크로 이동하여 성능 문제를 방지하거나 해결할 수 있습니다.
MCO(Machine Config Operator)는 OpenShift Container Platform 4.20 컨테이너 스토리지를 위한 보조 디스크를 마운트합니다.
이 인코딩된 스크립트는 다음 장치 유형에 대한 장치 이름만 지원합니다.
- SCSI 또는 SATA
-
/dev/sd* - 가상 장치
-
/dev/vd* - NVMe
-
/dev/nvme*[0-9]*n*
제한
-
새 디스크가 클러스터에 연결되면 etcd 데이터베이스가 root 마운트의 일부입니다. 기본 노드가 다시 생성되는 경우 보조 디스크 또는 의도한 디스크의 일부가 아닙니다. 결과적으로 기본 노드는 별도의
/var/lib/etcd마운트를 생성하지 않습니다.
사전 요구 사항
- 클러스터의 etcd 데이터 백업이 있습니다.
-
OpenShift CLI(
oc)가 설치되어 있습니다. -
cluster-admin권한이 있는 클러스터에 액세스할 수 있습니다. - 머신 구성을 업로드하기 전에 디스크를 추가합니다.
-
MachineConfigPool은metadata.labels[machineconfiguration.openshift.io/role]과 일치해야 합니다. 이는 컨트롤러, 작업자 또는 사용자 지정 풀에 적용됩니다.
이 절차에서는 루트 파일 시스템의 부분(예: /var/ )을 설치된 노드의 다른 디스크 또는 파티션으로 이동하지 않습니다.
컨트롤 플레인 머신 세트를 사용할 때 이 절차는 지원되지 않습니다.
프로세스
새 디스크를 클러스터에 연결하고 디버그 쉘에서
lsblk명령을 실행하여 노드에서 디스크가 감지되었는지 확인합니다.$ oc debug node/<node_name># lsblklsblk명령에서 보고한 새 디스크의 장치 이름을 확인합니다.다음 스크립트를 생성하고 이름을
etcd-find-secondary-device.sh로 지정합니다.#!/bin/bash set -uo pipefail for device in <device_type_glob>; do1 /usr/sbin/blkid "${device}" &> /dev/null if [ $? == 2 ]; then echo "secondary device found ${device}" echo "creating filesystem for etcd mount" mkfs.xfs -L var-lib-etcd -f "${device}" &> /dev/null udevadm settle touch /etc/var-lib-etcd-mount exit fi done echo "Couldn't find secondary block device!" >&2 exit 77- 1
- &
lt;device_type_glob>를 블록 장치 유형의 쉘 글로 바꿉니다. SCSI 또는 SATA 드라이브의 경우/dev/sd*를 사용합니다. 가상 드라이브의 경우/dev/vd*를 사용합니다. NVMe 드라이브의 경우/dev/nvme*[0-9]*를 사용합니다.
etcd-find-secondary-device.sh스크립트에서 base64로 인코딩된 문자열을 생성하고 해당 내용을 확인합니다.$ base64 -w0 etcd-find-secondary-device.sh다음과 같은 콘텐츠를 사용하여
etcd-mc.yml이라는MachineConfigYAML 파일을 만듭니다.apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfig metadata: labels: machineconfiguration.openshift.io/role: master name: 98-var-lib-etcd spec: config: ignition: version: 3.5.0 storage: files: - path: /etc/find-secondary-device mode: 0755 contents: source: data:text/plain;charset=utf-8;base64,<encoded_etcd_find_secondary_device_script>1 systemd: units: - name: find-secondary-device.service enabled: true contents: | [Unit] Description=Find secondary device DefaultDependencies=false After=systemd-udev-settle.service Before=local-fs-pre.target ConditionPathExists=!/etc/var-lib-etcd-mount [Service] RemainAfterExit=yes ExecStart=/etc/find-secondary-device RestartForceExitStatus=77 [Install] WantedBy=multi-user.target - name: var-lib-etcd.mount enabled: true contents: | [Unit] Before=local-fs.target [Mount] What=/dev/disk/by-label/var-lib-etcd Where=/var/lib/etcd Type=xfs TimeoutSec=120s [Install] RequiredBy=local-fs.target - name: sync-var-lib-etcd-to-etcd.service enabled: true contents: | [Unit] Description=Sync etcd data if new mount is empty DefaultDependencies=no After=var-lib-etcd.mount var.mount Before=crio.service [Service] Type=oneshot RemainAfterExit=yes ExecCondition=/usr/bin/test ! -d /var/lib/etcd/member ExecStart=/usr/sbin/setsebool -P rsync_full_access 1 ExecStart=/bin/rsync -ar /sysroot/ostree/deploy/rhcos/var/lib/etcd/ /var/lib/etcd/ ExecStart=/usr/sbin/semanage fcontext -a -t container_var_lib_t '/var/lib/etcd(/.*)?' ExecStart=/usr/sbin/setsebool -P rsync_full_access 0 TimeoutSec=0 [Install] WantedBy=multi-user.target graphical.target - name: restorecon-var-lib-etcd.service enabled: true contents: | [Unit] Description=Restore recursive SELinux security contexts DefaultDependencies=no After=var-lib-etcd.mount Before=crio.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/sbin/restorecon -R /var/lib/etcd/ TimeoutSec=0 [Install] WantedBy=multi-user.target graphical.target- 1
- &
lt;encoded_etcd_find_secondary_device_script>를 사용자가 언급한 인코딩된 스크립트 콘텐츠로 바꿉니다.
생성된
MachineConfigYAML 파일을 적용합니다.$ oc create -f etcd-mc.yml
검증 단계
노드의 디버그 쉘에서
grep /var/lib/etcd /proc/mounts명령을 실행하여 디스크가 마운트되었는지 확인합니다.$ oc debug node/<node_name># grep -w "/var/lib/etcd" /proc/mounts출력 예
/dev/sdb /var/lib/etcd xfs rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0