76
Copyright 2016 osci.kr. All Rights Reserved / Confidential Red Hat Enterprise Linux Server 7 운영자 기초 가이드 (주)오픈소스컨설팅 문경윤 차장

[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편

Embed Size (px)

Citation preview

Copyright 2016 osci.kr. All Rights Reserved / Confidential

Red Hat Enterprise Linux Server 7 운영자 기초 가이드

(주)오픈소스컨설팅

문경윤 차장

2

GRUB2 부트로더 관리 Ⅰ

시스템 시작 설정 관리

패키지 관리

Ⅳ 네트워크 관리

Ⅴ 스토리지 관리

Ⅵ crash dump 관리

3

1.1. 개요 1. GRUB2 부트로더 관리

Red Hat Enterprise Linux 7은 GNU Grand Boot Loader (GRUB) version 2 부트로더를 제공합니다. 이는 시스템 부팅 시 로드될 운영체제나 커널을 사용자가 선택하도록 허용합니다. GRUB2는 또한 사용자가 커널의 아규먼트를 보내는 것을 허용합니다. 설정파일(직접 편집하는 방법은 권장하지 않습니다) BIOS 기반 시스템 : /boot/grub2/grub.cfg UEFI 시스템 : /boot/efi/EFI/redhat/grub.cfg 설정 변경 방법 grub2-mkconfig 도구 이용 : 일반적으로 사용되는 방법입니다. /etc/grub.d 의 템플릿 섹션을 기반으로 설정파일을 만듭니다. 시스템에 여러 커널이 설치되어 있을 시 모든 커널에 공통적으로 파라미터 변경을 적용하고자 할 때 이 방법이 주로 사용됩니다. grubby 도구 이용 : grubby 명령어로 grub.cfg를 세밀하게 제어 가능합니다. 여러 커널이 설치되어 있을 시 앞으로도 계속 특정 커널로 부팅하고자 할 때 grubby가 사용될 수 있습니다. 그리고 커널별로 각각 다른 파라미터 변경을 적용하고자 할 때 grubby가 사용됩니다.

1.1.1. 설정 파일 및 도구

4

### BEGIN /etc/grub.d/10_linux ### menuentry 'Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-49928383-235b-4065-a9f1-2c0ebe14e033' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 1a4260c6-965d-478d-924a-a4456d04d654 else search --no-floppy --fs-uuid --set=root 1a4260c6-965d-478d-924a-a4456d04d654 fi linux16 /vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/vg00-root ro rd.lvm.lv=vg00/swap crashkernel=128M rd.lvm.lv=vg00/root initrd16 /initramfs-3.10.0-229.el7.x86_64.img } menuentry 'Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 0-rescue-2c72dd5b33b84c00a71eab66e0f3175d' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-2c72dd5b33b84c00a71eab66e0f3175d-advanced-49928383-235b-4065-a9f1-2c0ebe14e033' { load_video insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 1a4260c6-965d-478d-924a-a4456d04d654 else search --no-floppy --fs-uuid --set=root 1a4260c6-965d-478d-924a-a4456d04d654 fi linux16 /vmlinuz-0-rescue-2c72dd5b33b84c00a71eab66e0f3175d root=/dev/mapper/vg00-root ro rd.lvm.lv=vg00/swap crashkernel=128M rd.lvm.lv=vg00/root initrd16 /initramfs-0-rescue-2c72dd5b33b84c00a71eab66e0f3175d.img }

/boot/grub2/grub.cfg의 내용은 복잡하므로 직접 수정하는 방법은 권장하지 않습니다. 다음 페이지에서 설명하는 방법들로 GRUB2의 설정을 변경할 것을 권장합니다. (grub2-mkconfig, grubby)

1. GRUB2 부트로더 관리 1.1. 개요

1.1.2. /boot/grub2/grub.cfg 내용

5

/etc/default/grub 파일을 편집한 뒤 grub2-mkconfig 도구로 regenerate하는 방법을 사용합니다.

[root@localhost ~]# vi /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet" GRUB_DISABLE_RECOVERY="true"

GRUB_TIMEOUT=3

시스템 부팅 시 grub 스크린의 출력 시간을 변경하려면 GRUB_TIMEOUT key를 편집합니다.

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

아래 명령어로 /etc/default/grub 변경사항을 적용합니다.

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap transparent_hugepage=never"

파라미터를 변경하려면 GRUB_CMDLINE_LINUX key를 편집합니다.

각 key들에 대한 자세한 설명은 아래 URL을 참고하세요. https://www.gnu.org/software/grub/manual/html_node/Simple-configuration.html

BIOS 기반 시스템

[root@localhost ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

UEFI 시스템

1. GRUB2 부트로더 관리 1.2. /boot/grub2/grub.cfg 설정하기

1.2.1. grub2-mkconfig 도구 이용

6

모든 커널 메뉴 엔트리 출력

[root@localhost ~]# grubby --info=ALL index=0 kernel=/boot/vmlinuz-3.10.0-327.el7.x86_64 args="ro rd.lvm.lv=vg00/swap crashkernel=128M rd.lvm.lv=vg00/root systemd.debug LANG=ko_KR.euckr" root=/dev/mapper/vg00-root initrd=/boot/initramfs-3.10.0-327.el7.x86_64.img title=Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.1 (Maipo) index=1 kernel=/boot/vmlinuz-3.10.0-327.el7.x86_64 args="ro rd.lvm.lv=vg00/swap crashkernel=128M rd.lvm.lv=vg00/root systemd.debug LANG=ko_KR.euckr" root=/dev/mapper/vg00-root initrd=/boot/initramfs-3.10.0-327.el7.x86_64.img title=Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.1 (Maipo) with debugging index=2 kernel=/boot/vmlinuz-3.10.0-229.el7.x86_64 args="ro rd.lvm.lv=vg00/swap crashkernel=128M rd.lvm.lv=vg00/root" root=/dev/mapper/vg00-root initrd=/boot/initramfs-3.10.0-229.el7.x86_64.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64 index=3 kernel=/boot/vmlinuz-0-rescue-2c72dd5b33b84c00a71eab66e0f3175d args="ro rd.lvm.lv=vg00/swap crashkernel=128M rd.lvm.lv=vg00/root" root=/dev/mapper/vg00-root initrd=/boot/initramfs-0-rescue-2c72dd5b33b84c00a71eab66e0f3175d.img title=Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 0-rescue-2c72dd5b33b84c00a71eab66e0f3175d index=4 non linux entry

1. GRUB2 부트로더 관리 1.2. /boot/grub2/grub.cfg 설정하기

1.2.2. grubby 도구 이용

7

default 커널의 이름 출력

[root@localhost ~]# grubby --default-kernel /boot/vmlinuz-3.10.0-327.el7.x86_64

default 커널의 index 숫자 출력

[root@localhost ~]# grubby --default-index 0

default 커널을 원하는 커널로 변경 및 확인

[root@localhost ~]# grubby --set-default /boot/vmlinuz-3.10.0-229.el7.x86_64 [root@localhost ~]# grubby --default-kernel /boot/vmlinuz-3.10.0-229.el7.x86_64 [root@localhost ~]# grubby --default-index 2

--update-kernel 옵션은 신규 아규먼트를 추가하는 용도의 --args와 삭제 용도의 --remove-arguments와 조합하여 menu entry를 업데이트할 때 사용됩니다.

[root@localhost ~]# grubby --remove-args="rhgb quiet" --args=transparent_hugepage=never \ --update-kernel /boot/vmlinuz-3.10.0-229.el7.x86_64

--info 옵션을 사용하여 변경사항을 확인합니다.

[root@localhost ~]# grubby --info /boot/vmlinuz-3.10.0-229.el7.x86_64

1. GRUB2 부트로더 관리 1.2. /boot/grub2/grub.cfg 설정하기

1.2.2. grubby 도구 이용

8

2.1.1. systemctl을 이용하여 시작 서비스 설정 및 확인

[root@localhost ~]# systemctl list-unit-files -t service

시작 서비스 관리를 위해서 RHEL7에서는 systemd를 설정하는 명령어 systemctl을 이용합니다.

① 전체 서비스를 대상으로 시작 설정 확인

[root@localhost ~]# systemctl list-unit-files -t service <UNIT FILE>

② 특정 서비스의 시작 설정 상태 확인

형식)

[root@localhost ~]# systemctl list-unit-files -t service NetworkManager.service UNIT FILE STATE NetworkManager.service enabled

예)

③ 특정 서비스 대상으로 enable 또는 disable 설정

[root@localhost ~]# systemctl enable|disable <UNIT FILE>

[root@localhost ~]# systemctl disable NetworkManager.service

예)

형식)

2.1. 시작 서비스 및 타겟 설정 점검 2. 시스템 시작 설정 관리

9

2.1. 시작 서비스 및 타겟 설정 점검 2. 시스템 시작 설정 관리

아래 서비스들을 enable 권장합니다. accounts-daemon.service crond.service display-manager.service gdm.service [email protected] irqbalance.service kdump.service lvm2-monitor.service multipathd.service ntpd.service rsyslog.service rtkit-daemon.service sshd.service sysstat.service systemd-readahead-collect.service systemd-readahead-drop.service systemd-readahead-replay.service

2.1.1. systemctl을 이용하여 시작 서비스 설정 및 확인

10

2.1.2. rc.local 설정 및 확인

[root@localhost ~]# cat /etc/rc.d/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local [root@localhost ~]#

쉘스크립트 문법으로 작성 가능

rc.local 에 원하는 job이 올바르게 작성되어 있는지 확인합니다(shell script 문법으로 작성).

rc.local 파일은 RHEL7에서는 rc-local이란 이름의 systemd UNIT FILE에 의해 핸들링됩니다. 초기 default status는 inactive입니다.

[root@localhost ~]# systemctl status rc-local * rc-local.service - /etc/rc.d/rc.local Compatibility Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled) Active: inactive (dead) [root@localhost ~]#

[root@localhost ~]# chmod u+x /etc/rc.d/rc.local [root@localhost ~]# ll /etc/rc.d/rc.local -rwxr--r--. 1 root root 473 Oct 12 08:39 /etc/rc.d/rc.local [root@localhost ~]#

아래와 같이 퍼미션이 설정되어야 다음 리부팅 때부터 작동, active status를 유지합니다.

2.1. 시작 서비스 및 타겟 설정 점검 2. 시스템 시작 설정 관리

11

2.1.3. systemd의 target 설정

RHEL6의 init runlevel은 RHEL7으로 오면서 systemd의 target으로 대체되었습니다.

2.1. 시작 서비스 및 타겟 설정 점검 2. 시스템 시작 설정 관리

Runlevel Redirecting to Target

RHEL6 init RHEL7 systemd

runlevel 0 poweroff.target

runlevel 1 rescue.target

runlevel 2,3,4 multi-user.target

runlevel 5 graphical.target

runlevel 6 reboot.target

target 변경 방법은 아래와 같습니다. 변경하고 리붓하면 됩니다. 시스템 운영 중엔 multi-user.target이나 graphical.target을 유지하면 됩니다.

[root@localhost ~]# systemctl set-default multi-user.target

[root@localhost ~]# systemctl set-default graphical.target

현재 target 확인

[root@localhost ~]# systemctl get-default

12

2.1.3. systemd의 target 설정

2.1. 시작 서비스 및 타겟 설정 점검 2. 시스템 시작 설정 관리

gnome-initial-setup을 비활성할 수 없음, user 생성을 강제해야 함 Bug 1226819 - gnome-initial-setup cannot be disabled, forces user creation https://bugzilla.redhat.com/show_bug.cgi?id=1226819

원인 아래 3가지 조건이 모두 만족될 경우 재부팅 때마다 gnome-initial-setup으로 재진입됩니다.

RHEL 7.0 ~ 7.2(latest)

gnome-initial-setup 패키지 설치

UID 500 이상의 user가 하나도 없음

이 버그는 버그질라에 보고되어 있으며 fix 방법이 나와 있지 않은 것으로 알려져 있습니다.

Bug 1226819 - gnome-initial-setup cannot be disabled, forces user creation

https://bugzilla.redhat.com/show_bug.cgi?id=1226819

RHEL 7은 Fedora 19를 백포팅하여 패키징된 배포판입니다.

bug가 fix되지 못한 채 Fedora 20 이 EOL되는 바람에 RHEL 7.2에도 bug가 fix되지 못한 gnome-initial-setup이 포함되어 있습니다.

문제 gnome-initial-setup으로 진입될 시 반드시 콘솔 상에서 setup을 수동으로 진행해야 하며 진행하지 않을 시 부팅이 완료되지 못해 시스템에 ssh 등으로 원격 접속할 수 없습니다.

13

2.1.3. systemd의 target 설정

2.1. 시작 서비스 및 타겟 설정 점검 2. 시스템 시작 설정 관리

gnome-initial-setup을 비활성할 수 없음, user 생성을 강제해야 함 Bug 1226819 - gnome-initial-setup cannot be disabled, forces user creation https://bugzilla.redhat.com/show_bug.cgi?id=1226819

조치 gnome-initial-setup 패키지의 bug가 fix되지는 않았지만 2가지의 workaround가 제공되고 있으니 아래 두 방법 중 하나를 선택 적용하시면 됩니다.

① gnome-initial-setup 패키지 삭제

# yum remove gnome-initial-setup

② /etc/gdm/custom.conf 에 아래 설정 적용

[daemon]

InitialSetupEnable=False

14

2.2. /etc/fstab 점검

2.2.1. /etc/fstab 개요

/etc/fstab 점검 필요성 시스템 부팅 시 자동으로 마운트되어야 할 장치 정보 명시되어 있어 설정이 잘못되어 있을 경우 재부팅하면 정상 부팅될 수 없습니다(원격으로는 해결 불가능). /etc/fstab에 명시되어 있는 각종 옵션들에 대한 이해를 정확히 하지 못하면 추후 운영 시 디스크 구성 변경 작업이 어려울 수 있습니다. 데이터 저장 매체와 직접적인 관련이 있는 설정으로 마운트되어 있어야 할 장치가 마운트되어 있지 않은 상태로 운영 들어갈 시 데이터 무결성 유지에 치명적일 수 있다 (SAN 또는 NAS 공유볼륨을 여러 노드가 마운트하는 경우 마운트하지 못한 노드는 로컬 경로에 데이터를 쌓는 우를 범할 수 있음).

2. 시스템 시작 설정 관리

15

2.2.2. /etc/fstab 점검

▼ RHEL7 /etc/fstab 예

첫번째 필드에는 LVM 논리볼륨이 아닐 경우 가급적 경로 기반 장치명(path based device name)이 아닌 UUID로 명시 권장합니다.

init 기반 시스템인 RHEL6 시절까지 필요로 했던 /etc/fstab의 NFS 클라이언트 설정 옵션이었던 _netdev는 systemd 기반의 RHEL7에서는 사라졌습니다.

# # /etc/fstab # Created by anaconda on Mon Aug 3 15:28:48 2015 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # ### vg00 /dev/mapper/vg00-root / xfs defaults 0 0 UUID=802738d7-4d6e-4ecd-9c33-683e2b140e36 /boot xfs defaults 0 0 /dev/mapper/vg00-home /home xfs defaults 0 0 /dev/mapper/vg00-opt /opt xfs defaults 0 0 /dev/mapper/vg00-tmp /tmp xfs defaults 0 0 /dev/mapper/vg00-var /var xfs defaults 0 0 /dev/mapper/vg00-crash /var/crash xfs defaults 0 0 /dev/mapper/vg00-swap swap swap defaults 0 0 172.28.51.20:/EAI2MES /EAI2MES nfs defaults 0 0

blkid 명령어로 장치의 uuid 확인 가능

NFS 클라이언트 설정

2. 시스템 시작 설정 관리 2.2. /etc/fstab 점검

16

2.2.2. /etc/fstab 점검

# # /etc/fstab # Created by anaconda on Mon Aug 3 15:28:48 2015 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # ### vg00 /dev/mapper/vg00-root / xfs defaults 0 0 UUID=802738d7-4d6e-4ecd-9c33-683e2b140e36 /boot xfs defaults 0 0 /dev/mapper/vg00-home /home xfs defaults 0 0 /dev/mapper/vg00-opt /opt xfs defaults 0 0 /dev/mapper/vg00-tmp /tmp xfs defaults 0 0 /dev/mapper/vg00-var /var xfs defaults 0 0 /dev/mapper/vg00-crash /var/crash xfs defaults 0 0 /dev/mapper/vg00-swap swap swap defaults 0 0 172.28.51.20:/EAI2MES /EAI2MES nfs defaults 0 0

fs_freq(dump frequency)

fs_passno(file system check order)

RHEL7의 /etc/fstab의 XFS의 5, 6번째 field의 기본값이 "0 0"인 이유 fs_freq and fs_passno is set to 0 with XFS on Red Hat Enterprise Linux 7.1 https://access.redhat.com/solutions/1556513

▼ RHEL7 /etc/fstab 예

2. 시스템 시작 설정 관리 2.2. /etc/fstab 점검

17

2.2.2. /etc/fstab 점검

fs_freq(dump frequency) xfsdump 명령어의 man page를 보면 /etc/fstab의 dump frequency는 아래 문구와 같이 더 이상 지원되지 않는 것으로 확인됩니다. 따라서 "0" 이외의 값이 무효하므로 "0"으로 두는 것이 맞습니다. "The dump frequency field of /etc/fstab is not supported." fs_passno(file system check order) ext3, 4는 OS 부팅 초반 마운트 과정 중 user space상에서 저널 복구를 시도하며, 이 때 /etc/fstab이 참조됩니다. xfs는 kernel space에서 저널 복구를 합니다. fstab은 "fsck.filesystemtype" 형식의 명령어를 실행하게 되는데 fsck.xfs 메뉴얼 페이지에 의하면 "fsck.xfs" 명령어는 아무런 작업을 하지 않습니다. 또한 xfs는 마운트되어 있는 파일시스템의 commit되지 않은 저널을 replay하는 일부 기능이 있기 때문에 unclean shutdown 후 reboot 시 fsck 작업이 필요하지 않습니다. 따라서 저널 복구 옵션으로 참조되었던 /etc/fstab의 fs_passno 필드는 부팅 중 더 이상 참조되지 않습니다. 이러한 xfs의 특징들로 인해 RHEL7 설치 과정에서 인스톨러인 anaconda는 XFS 파일시스템 작업 시 fs_freq와 fs_passno를 "0 0"으로 만듭니다. 따라서 디폴트인 “0 0”으로 그대로 두시기 바랍니다.

RHEL7의 /etc/fstab의 XFS의 5, 6번째 field의 기본값이 "0 0"인 이유 fs_freq and fs_passno is set to 0 with XFS on Red Hat Enterprise Linux 7.1 https://access.redhat.com/solutions/1556513

2. 시스템 시작 설정 관리 2.2. /etc/fstab 점검

18

2.3. NTP 구성 점검

2.3.1. ntpd 서비스 구동 및 설정 파일 점검

[root@localhost ~]# rpm –qa | grep ntp

[root@localhost ~]# systemctl enable ntpd.service

[root@localhost ~]# cat /etc/ntp.conf | egrep -iv '^$|^#'

driftfile /var/lib/ntp/drift

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

restrict -6 ::1

server 0.rhel.pool.ntp.org

server 1.rhel.pool.ntp.org

server 2.rhel.pool.ntp.org

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

[root@localhost ~]#

[root@localhost ~]# systemctl start ntpd.service

[root@localhost ~]# ntpq –p

remote refid st t when poll reach delay offset jitter

====================================================================

send.mx.cdnetwo 121.182.147.191 2 u 880 1024 377 7.471 -0.643 3.559

211.233.84.186 121.182.147.191 2 u 826 1024 377 9.812 -2.044 0.500

*121.182.147.191 .GPS. 1 u 244 1024 377 12.267 4.428 6.114

[root@localhost ~]# 첫 번째 필드에 *나 +표시가 나와 있어야 정상 (ntpd 초기 구동/재구동 시엔 수 분 정도 지나야 sync 시작)

서버 자신에 대해서는 모든 권한을 가짐 restrict 설정은 peer 들이 본 서버로 sync 하는 것에 대한 제한을 한다.

원하는 ntp 서버 설정

2. 시스템 시작 설정 관리

19

3.1. yum 명령어로 패키지 관리

3.1.1. yum repo 설정

[root@localhost ~]# cat /etc/yum.repos.d/local.repo [base] name=base baseurl=file:///root/OSC/yum/base enabled=1 gpgcheck=0 [updates] name=updates baseurl=file:///root/OSC/yum/updates enabled=1 gpgcheck=0

Step 1. repo 구성 (local, ftp, http 지원)

.repo 확장자를 갖는 파일이어야 함

▼ DVD의 소스를 /root/OSC/yum/base에 복사해 놓았을 경우 repo 설정

채널 단위로 저장소를 추가 설정할 수 있다. updates 채널을 추가하였다. 채널명은 자유롭게 지정할 수 있다.

[root@localhost ~]# cat /etc/yum.repos.d/http.repo [base] name=base baseurl=http://URL enabled=1

▼ http 서버 소스를 repo로 설정하는 경우

3. 패키지 관리

20

3.1. yum 명령어로 패키지 관리

[root@localhost ~]# cat /etc/yum.repos.d/local.repo [base] name=base baseurl=file:///root/OSC/yum/base enabled=1 gpgcheck=0 [updates] name=updates baseurl=file:///root/OSC/yum/updates enabled=1 gpgcheck=0

각 채널별로 repodata라는 이름의 디렉토리에 yum repo metadata가 저장되어 있어 이 metadata가 yum을 이용한 패키지 관리를 가능하게 합니다.

3. 패키지 관리

[root@localhost base]# ls –l /root/OSC/yum/base total 372 dr-xr-xr-x. 4 root root 52 Oct 31 00:03 addons dr-xr-xr-x. 3 root root 17 Oct 31 00:03 EFI -r--r--r--. 1 root root 8266 Apr 4 2014 EULA -r--r--r--. 1 root root 18092 Mar 6 2012 GPL dr-xr-xr-x. 3 root root 54 Oct 31 00:03 images dr-xr-xr-x. 2 root root 4096 Oct 31 00:03 isolinux dr-xr-xr-x. 2 root root 41 Oct 31 00:03 LiveOS -r--r--r--. 1 root root 114 Oct 30 23:54 media.repo dr-xr-xr-x. 2 root root 241664 Oct 31 00:03 Packages dr-xr-xr-x. 24 root root 4096 Oct 31 00:03 release-notes dr-xr-xr-x. 2 root root 4096 Oct 31 00:03 repodata -r--r--r--. 1 root root 3375 Oct 23 22:25 RPM-GPG-KEY-redhat-beta -r--r--r--. 1 root root 3211 Oct 23 22:25 RPM-GPG-KEY-redhat-release -r--r--r--. 1 root root 1568 Oct 31 00:03 TRANS.TBL [root@localhost base]#

[root@localhost base]# ls -l /root/OSC/yum/base/repodata total 15284 -r--r--r--. 1 root root 1079161 Oct 30 23:44 07e4091c2566d0daa4326f0e28b983e1b0c4e0fcfe514441c1f9a0ee7c7001fc-other.xml.gz -r--r--r--. 1 root root 138768 Oct 30 23:44 08e566b3f6f6ad461fe70e67c12f7e41042079e9b77cbdd32b5f4a5a020876b1-comps-Server.x86_64.xml.gz -r--r--r--. 1 root root 3787558 Oct 30 23:44 30cd8235ba99c6dcc59e49f9636ae8eaff0eb99eeaa4fd149354481487598164-primary.sqlite.bz2 -r--r--r--. 1 root root 3376033 Oct 30 23:44 34a02f7b1f27a52fe64c82fa602af857cf53ea115f412fd81cb0c97f7cb4be96-filelists.sqlite.bz2 -r--r--r--. 1 root root 1831018 Oct 30 23:44 5509e5f3a45df9f4d938b8dc97826a0165fc197aea9eca0f0994721833ef691d-primary.xml.gz -r--r--r--. 1 root root 641345 Oct 30 23:43 81c149ffb2267c59a3e6405766b5ff3dc78e0637033e9f5aef564538359ff281-comps-Server.x86_64.xml -r--r--r--. 1 root root 1503862 Oct 30 23:44 8831f4d94793cb4092a3d747f8c17b20c592b8e9132940be76378d29aa755f46-other.sqlite.bz2 -r--r--r--. 1 root root 3256244 Oct 30 23:44 d9a2b6d57c2cdf6f29799bca1c538a8e96cbb14ea3184002f4083ef709249671-filelists.xml.gz -r--r--r--. 1 root root 1619 Oct 30 23:44 e67a1b710afb8343fb2c1fef5c670e25b46e6aa25b736c2db657bce6cd356a4d-productid.gz -r--r--r--. 1 root root 2159 Oct 30 18:20 productid -r--r--r--. 1 root root 4183 Oct 30 23:44 repomd.xml -r--r--r--. 1 root root 3093 Oct 31 00:03 TRANS.TBL [root@localhost base]#

3.1.1. yum repo 설정

21

3.1. yum 명령어로 패키지 관리

[root@localhost ~]# cat /etc/yum.repos.d/local.repo [base] name=base baseurl=file:///root/OSC/yum/base enabled=1 gpgcheck=0 [updates] name=updates baseurl=file:///root/OSC/yum/updates enabled=1 gpgcheck=0

createrepo 명령어를 이용하여 커스텀 채널을 위한 yum metadate를 생성할 수 있습니다. createrepo는 createrepo 패키지에 포함되어 있습니다.

3. 패키지 관리

[root@localhost updates]# rpm -qa createrepo createrepo-0.9.9-23.el7.noarch [root@localhost updates]# createrepo /root/OSC/yum/updates Spawning worker 0 with 27 pkgs Spawning worker 1 with 26 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@localhost updates]#

[root@localhost updates]# ls -l /root/OSC/yum/updates total 118236 -rw-r--r-- 1 root root 1034528 Mar 24 09:59 bash-4.2.46-19.el7.x86_64.rpm -rw-r--r-- 1 root root 257512 Mar 24 09:59 device-mapper-1.02.107-5.el7.x86_64.rpm -rw-r--r-- 1 root root 170800 Mar 24 09:59 device-mapper-event-1.02.107-5.el7.x86_64.rpm -rw-r--r-- 1 root root 172352 Mar 24 09:59 device-mapper-event-libs-1.02.107-5.el7.i686.rpm -rw-r--r-- 1 root root 172756 Mar 24 09:59 device-mapper-event-libs-1.02.107-5.el7.x86_64.rpm -rw-r--r-- 1 root root 358636 Mar 24 09:59 device-mapper-persistent-data-0.5.5-1.el7.x86_64.rpm (중략) drwxr-xr-x 2 root root 4096 Mar 24 10:59 repodata -rw-r--r-- 1 root root 441944 Mar 24 09:59 tzdata-2016a-1.el7.noarch.rpm -rw-r--r-- 1 root root 180208 Mar 24 09:59 tzdata-java-2016a-1.el7.noarch.rpm [root@localhost updates]#

3.1.1. yum repo 설정

22

Step 2. enable된 repolist 확인

[root@localhost ~]# yum repolist Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. repo id repo name status base base 4,620 updates updates 53 repolist: 4,673

Step 3. 패키지그룹 리스트 확인

[root@localhost ~]# yum grouplist hidden Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Available Environment Groups: Minimal Install Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI Installed Groups: Additional Development Base (이하 생략)

3. 패키지 관리 3.1. yum 명령어로 패키지 관리

3.1.1. yum repo 설정

23

3.1.2. yum 기본 사용

[root@localhost ~]# yum [ -y ] groupinstall <name of package group>

[root@localhost ~]# yum [ -y ] install <name of indivisual package>

[root@localhost ~]# yum [ -y ] remove <name of indivisual package>

패키지 그룹 설치

개별 패키지 설치

개별 패키지 삭제

[root@localhost ~]# yum [ -y ] groupremove <name of package group>

패키지 그룹 삭제

3. 패키지 관리 3.1. yum 명령어로 패키지 관리

24

3.1.3. yum-utils 사용하여 향상된 저장소 관리

3. 패키지 관리 3.1. yum 명령어로 패키지 관리

# yum install --downloadonly --downloaddir=<directory> <name of indivisual package>

개별 패키지를 설치하지 않고 의존성 있는 패키지들까지 local에 다운로드

yum-utils 패키지가 설치되어 있다면 향상된 기능의 패키지 배포 및 관리가 가능합니다.

Red Hat Enterprise Linux Server는 기본적으로 RHN(Red Hat Network)으로부터 패키지를 다운로드하여 설치합니다. 대부분의 기업 환경에서는 보안상 네트워크 통신이 제한적이므로 시스템이 RHN에 액세스할 수 없는 경우가 많습니다. yum-utils 패키지가 제공하는 downloadonly 플러그인이나 yumdownloader 바이너리는 패키지를 직접 설치하지 않고 로컬에 다운로드하는 기능을 제공하므로 RHN에 액세스할 수 있는 시스템에서 패키지를 다운로드하여 기업 시스템에 업로드, 커스텀 채널 구성하여 사용할 수 있습니다.

# yum groupinstall --downloadonly --downloaddir=<directory> <name of indivisual package>

패키지 그룹을 설치하지 않고 의존성 있는 패키지들까지 local에 다운로드

# yumdownloader <name of indivisual package>

개별 패키지를 설치하지 않고 local에 다운로드

25

3.1.3. yum-utils 사용하여 향상된 저장소 관리

3. 패키지 관리 3.1. yum 명령어로 패키지 관리

yum-utils 패키지에 속한 reposync 명령어로 채널 단위의 패키지 sync를 할 수 있습니다.

[root@localhost ~]# yum repolist Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. repo id repo name status base base 4,620 updates updates 53 repolist: 4,673

yum repolist를 통해 활성화된 repoi id를 확인합니다.

[root@localhost ~]# reposync [ -r < repo id >] [ –n ] [< directory >]

[root@localhost ~]# yum repolist all

비활성화되어 있는 repo id도 확인하려면 all 아규먼트를 추가 입력합니다.

[root@localhost ~]# yum-config-manager --enable <repo id> [root@localhost ~]# yum-config-manager --disable <repo id>

repo id를 활성/비활성하기 위해 yum-config-manager 명령어를 이용합니다.

repo를 sync합니다. –r 옵션을 주지 않으면 활성화된 모든 repo를 sync합니다.

-r REPOID, --repoid=REPOID

Specify repo ids to query, can be specified multiple times (default is all enabled).

-n, --newest-only

Download only newest packages per-repo

26

3.1.4. yum 좀 더 잘 사용하기

3. 패키지 관리 3.1. yum 명령어로 패키지 관리

① yum repo 세팅을 하지 않아도 yum 사용 가능합니다. localinstall/localupdate 옵션을 이용합니다. 의존성 있는 패키지가 모두 준비되어 있어야 합니다.

[root@localhost ~]# yum localinstall rpmfile1 [rpmfile2] [...]

설치

[root@localhost ~]# yum localupdate rpmfile1 [rpmfile2] [...]

업데이트

② 패키지를 재설치하려면 reinstall 옵션을 이용합니다.

[root@localhost ~]# yum reinstall package1 [package2] [...]

③ 패키지를 다운그레이드하려면 downgrade 옵션을 이용합니다.

[root@localhost ~]# yum downgrade package1 [package2] [...]

27

3.2.1. rpm 기본 사용

3. 패키지 관리 3.2. rpm 명령어로 패키지 관리

RPM은 Linux Standard Base의 표준 패키지 포맷 중 하나로 레드햇을 중심으로 여러 다른 배포판들도 사용하고 있는 패키지 관리 시스템입니다.

의존성도 고려하여 설치해 주는 yum을 사용하는 것이 권장되나 의존성이 복잡하지 않은 간단한 패키지 설치에는 rpm도 유용하게 사용될 수 있습니다.

[root@localhost ~]# rpm -ivh rpmfile1 [rpmfile2] [...]

설치

[root@localhost ~]# rpm -Uvh rpmfile1 [rpmfile2] [...]

업데이트(기존에 설치된 것이 없을 경우 설치된다)

의존성 무시하고 강제 설치

[root@localhost ~]# rpm -ivh --nodeps rpmfile1 [rpmfile2] [...]

다운그레이드

[root@localhost ~]# rpm -Uvh [ --nodeps ] --oldpackage rpmfile1 [rpmfile2] [...]

재설치

[root@localhost ~]# rpm -Uvh [ --nodeps ] --replacepkgs rpmfile1 [rpmfile2] [...]

28

4.1. 네트워크 설정 전 하드웨어/드라이버 점검

4.1.1. lspci - NIC 하드웨어 인식 상태 확인

▼ lspci 로 확인

[root@localhost ~]# lspci | grep -i ethernet 01:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06) 01:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06) 05:05.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10) [root@localhost ~]#

lspci에서 NIC가 확인되지 않으면 하드웨어적으로 인식되고 있지 않음을 의미합니다.

노란색 테두리 부분은 PCI 장치 고유 식별번호로 이를 통해 원격지에서도 PCI device의 장착 현황을 파악할 수 있습니다. 2port NIC(Intel)가 1장, 1port NIC(Realtek) 1장 장착되어 있음을 알 수 있습니다.

4. 네트워크 관리

NIC가 OS에 하드웨어적으로 올바르게 인식되고 있는지 확인하는 것이 첫 번째 필수사항입니다. lspci 명령어로 확인합니다.

29

4.1.2. lsmod - NIC 모듈 로드 여부 확인

▼ lsmod 로 확인

[root@localhost ~]# lsmod r8169 51483 0 mii 5335 1 r8169 e1000e 221811 0 [root@localhost~]#

4. 네트워크 관리

※ 확인될 수 있는 대표적인 모듈들 r8139, r8169 (Realtek) e100, e1000, e1000e, igb, ixgbe (Intel) bnx2, tg3 (Broadcom) vmnet, vmxnet3 (VMWare 전용) virtio_net (KVM/RHEV 전용)

network 서비스를 시작 시 모듈을 찾을 수 없다고 나오며 인터페이스가 활성화되지 못하는 이유는 크게 두 가지입니다. ▶ 모듈이 설치되어 있지 않은 경우 - 커널에 기본 내장되지 않은 경우가 대부분이며 NIC 제조사에서 제공하는 별도 인스톨러(스크립트 또는 rpm 형태) 등으로 설치 ▶ 모듈을 설치했으나 별도 컴파일하여 NIC 모듈을 설치한 경우 – depmod로 커널에 인식시켜 주어야 함

[root@localhost ~]# depmod -a

NIC의 하드웨어 인식에 문제가 없다면 NIC 칩셋을 지원하는 module(driver)이 올바르게 load되어 있는지 확인해야 합니다.

4.1. 네트워크 설정 전 하드웨어/드라이버 점검

30

4.1.3. 원하는 NIC 인터페이스를 OS에서 식별하기

4. 네트워크 관리

이 많은 NIC들을 OS에서 어떻게 구별하나?

ethtool의 -p 또는 --identify 옵션을 이용하여 대부분의 NIC에 led 점멸을 일으킬 수 있습니다.

# ethtoo -p|--identify <interface>

-p 옵션이 동작하려면 인터페이스의 상태가 up 이어야 합니다. ip address 등의 네트워크 정보가 아직 설정되지 않은 NIC라면 아래와 같이 up시킵니다.

# ifconfig <interface> up

ip addr 명령어로 NIC의 state가 Down에서 Up으로 바뀐 것이 확인되면 이제 ethtool의 -p 옵션이 유효할 것입니다.

[root@localhost ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:ae:08:ec brd ff:ff:ff:ff:ff:ff inet 192.168.159.139/24 brd 192.168.159.255 scope global dynamic eno16777728 valid_lft 1410sec preferred_lft 1410sec inet6 fe80::20c:29ff:feae:8ec/64 scope link valid_lft forever preferred_lft forever [root@localhost ~]#

4.1. 네트워크 설정 전 하드웨어/드라이버 점검

31

4.1.3. 원하는 NIC 인터페이스를 OS에서 식별하기

4. 네트워크 관리 4.1. 네트워크 설정 전 하드웨어/드라이버 점검

ifconfig up eth0와 ifup eth0 간 차이점은 무엇인가? What is the difference between 'ifconfig up eth0' and 'ifup eth0'? https://access.redhat.com/solutions/27166

ifconfig와 ifup, ifdown은 네트워크 인터페이스를 활성화합니다. ifconfig는 네트워크 인터페이스를

직접 컨트롤하지만 ifup/ifdown은 /etc/sysconfig/network-scripts/ifup- 이나 ifdown- 스크립트를

실행합니다. 스크립트는 ip 명령어를 사용합니다.

ifconfig와 ip 명령어는 네트워크 인터페이스를 활성 또는 비활성화하기 위해 ioctl()을 사용합니다.

ifconfig는 네트워크 인터페이스 IFF_UP | IFF_RUNNING 을 flag하나, ip는 IFF_UP를 flag합니다.

ifconfig up eth0 은 eth0을 활성화하나 IP 주소를 설정하지 않습니다. ifup은 ifup-eth* 스크립트를

사용하므로 ifup eth0 은 IP 주소를 설정하거나 ifcfg-eth0에 다른 옵션을 설정합니다.

ifup 명령어는 network-scripts 디렉토리에 구성된 static routes를 구성합니다. ifconfig는 그렇게 하지

않습니다.

32

4.1.4. ethtool - 네트워크 드라이버와 하드웨어 세팅에 대해 query하거나 제어

[root@localhost networking]# ethtool eno1 Settings for eno1: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Link partner advertised link modes: 10baseT/Half 100baseT/Half 1000baseT/Full Link partner advertised pause frame use: Symmetric Link partner advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: off Supports Wake-on: g Wake-on: g Current message level: 0x000000ff (255) drv probe link timer ifdown ifup rx_err tx_err Link detected: yes

ip address를 설정하기 전 ethtool 명령어로 장치 간 데이터 링크 계층 연결이 정상인지 확인합니다.

4. 네트워크 관리

① local NIC가 지원하는 link modes 스펙 정보 ② local NIC가 advertise받은 link mode의 종류 ③ local NIC에 연결된 네트워크 장치(Link Partner)가 advertise받은 link mode의 종류(NIC에 따라 출력되지 않는 경우도 있다) ④ ① ~ ③의 결과에 기반하여 local NIC가 네트워크 장치와 맺은 연결 정보

최하단부의 Link detected가 no로 나올 경우 NIC가 네트워크 장비와 Data Link Layer 연결이 이루어지지 않은 상태이므로 아래 순서로 점검합니다. Step 1) 인터페이스가 OS에서 활성화되었는지 확인 # ip addr (state가 Up인지 확인) Step 2) 스위치의 port가 활성화되었는지 확인 Step 3) NIC나 케이블, 스위치포트 물리적 문제인지 확인

4.1. 네트워크 설정 전 하드웨어/드라이버 점검

33

4.2.1. Consistent Network Device Naming

4. 네트워크 관리 4.2. RHEL7 Consistent Network Device Naming Overview

RHEL7의 네트워크 장치 네이밍은 아래의 과정을 거쳐 이루어집니다.

Procedure Rule file 설명 비고

Step 1 N/A 부팅 시 initramfs 으로부터 실행된 udev에 의해 모든

네트워크 인터페이스가 ethX 형식으로 인식됩니다. N/A

Step 2

/usr/lib/udev/rules.d/60-net.rules Root 파일시스템 mount되면서 udev helper utility(/lib/udev/rename_device)가 /usr/lib/udev/rules.d/60-net.rules을 참고하여 인터페이스 이름이 생성됩니다. /etc/sysconfig/network-scripts/ifcfg-suffix 파일에 HWADDR 엔트리가 있고 ifcfg 파일명과 ifcfg 파일의 DEVICE directive가 일치하는 조건이 만족되어 있다면 suffix 와 동일한 이름의 인터페이스가 생성됩니다.

N/A

Step 3

/usr/lib/udev/rules.d/71-biosdevname.rules 하드웨어가 biosdevname을 지원하고 RHEL7의 command-line parameter가 biosdevname=1 조건이 만족되면 /usr/lib/udev/rules.d/71-biosdevname.rules을 참고하여 biosdevname 형식의 인터페이스 이름이 생성됩니다.

N/A

Step 4

/lib/udev/rules.d/75-net-description.rules systemd-udev 네이밍 스키마에 의하여 내부 udev 장치 속성값에 기반한 인터페이스 이름이 생성됩니다. 속성값으로 ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH, ID_NET_NAME_MAC 등이 있습니다. 일부 장치의 속성은 정의되지 않을 수 있습니다.

총 5단계의 system-udev의 네이밍 스키마 정책이 적용됩니다. 스키마 1, 2, 3이 기본 적용되고 스키마4는 사용자가 직접 정의해야 적용됩니다. 스키마 5는 스키마 1 ~ 4 메소드가 모두 fail될 경우 적용되며 전통적 네이밍(예: eth0)이 적용됩니다.

Step 5

/usr/lib/udev/rules.d/80-net-name-slot.rules Step 1 또는 2에서 네이밍되지 못하고 커널 파라미터 net.ifnames=0이 아니라면(default 0)이라면 ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH 속성에 따라 네이밍됩니다(Step 4와 유사).

34

4.2.2. 네이밍 스키마 계층구조

4. 네트워크 관리

systemd-udev는 아래의 네이밍 스키마에 의해 인터페이스 이름을 결정합니다. 대부분의 경우 스키마 1, 2, 3에 의해 이름이 결정됩니다.

eno1

enp2s0

enx78e7d1ea46da

YES

No

YES

YES

YES

No

No

No

스키마 5 전통적 방식인 eth* 적용

스키마 4 MAC address 이름 사용 룰이 작성되어 있는가?

스키마 3 하드웨어 커넥터의

물리적 위치 사용방식을 적용할 수 있는가?

스키마 2 PCI 익스프레스 핫플러그 슬롯

장치인가?

스키마 1 온보드 장치인가?

ens1

4.2. RHEL7 Consistent Network Device Naming Overview

35

4.2.3. 커스텀 네이밍을 사용

4. 네트워크 관리

커스텀 네이밍을 사용하려면 udev helper utility(/lib/udev/rename_device)에 의한 네이밍을 사용하는 것이 간편합니다. /etc/sysconfig/network-scripts/ifcfg-suffix 파일을 아래의 규칙에 맞게 설정하면 udev helper utility가 /usr/lib/udev/rules.d/60-net.rules 에 기반하여 인터페이스를 네이밍합니다. command-line parameter가 net.ifnames=1(기본값)인 상태에서 작업합니다.

Step 1) MAC address를 /sys/class/net/<interface>/address에서 확인합니다.

4.2. RHEL7 Consistent Network Device Naming Overview

Step 2) /etc/sysconfig/network-scripts/ifcfg-suffix 파일명을 원하는 인터페이스명에 맞게 변경합니다.

Step 3) ifcfg-suffix 파일에 HWADDR directive를 작성합니다. DEVICE, NAME directive도 바뀔 인터페이스명으로 수정합니다.

Step 4) 시스템을 reboot합니다.

36

4.2.3. 커스텀 네이밍을 사용

4. 네트워크 관리 4.2. RHEL7 Consistent Network Device Naming Overview

왜 RHEL7 system은 "systemd-udevd: error changing net interface name ethX to ethY: File exists" ? 에러를 내며 이름 바꾸기에 실패하는가? Why RHEL7 system is failing in renaming the interfaces with error "systemd-udevd: error changing net interface name ethX to ethY: File exists" ? https://access.redhat.com/solutions/1422203

복수의 NIC 환경이면서 ethX 스타일 기반의 인터페이스명을 원할 시 command-line parameter에 net.ifname=0 을 적용하지 마십시오. 적용 시 initramfs 부트 과정(kernel namespace)에서 네이밍된 ethX 인터페이스 이름과 같은 이름으로는 systemd-udev가 swap하지 못합니다. 그러므로 system-udev의 user namespace 동작(root filesystem 내의 udev 유틸리티 및 rules에 의한 동작)에 의한 ethX rename 과정에서 kernel namespace의 ethX 이름 정보와 일부 충돌이 일어나 시스템에 인식된 몇몇 인터페이스들의 이름이 ifcfg-suffix 의 정보와 맞지 않게 됩니다. 리부팅 때마다 나타날 수 있으므로 net.ifnames=0 환경에서는 ethX가 아닌 다른 커스텀 네이밍(예: net0, …)을 사용해야 합니다.

37

4.3.1. 단일 NIC 네트워크 설정

설정파일 아래와 같이 작성

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-<interface name> DEVICE= <interface name> HWADDR=xx:xx:xx:xx:xx:xx /sys/class/net/<interface name>/address 의 값을 넣음 BOOTPROTO=static ONBOOT=yes IPADDR=10.0.0.10 NETMASK=255.255.255.0 GATEWAY=10.0.0.1

[root@localhost ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=localhost.localdomain NOZEROCONF=yes

4. 네트워크 관리 4.3. 기본 네트워크 설정

How do I disable the zeroconf route so that the system will boot without the 169.254.0.0 / 255.255.0.0 route? https://access.redhat.com/solutions/8627 To not set a route for dynamic link-local addresses.

38

4.4. Bonding 설정

4.4.1. 본딩 개요

MS의 teaming, Cisco의 Ether Channel 등과 더불어 네트웍 대역폭 증가 및 이중화를 목적으로 리눅스에서 지원하는 Link Aggregation 기술

4.4.2. 설정

[root@localhost ~]# /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 IPADDR=192.168.0.10 NETMASK=255.255.255.0 GATEWAY=192.168.0.1 ONBOOT=yes BOOTPROTO=none USERCTL=no BONDING_OPTS=“mode=1 miimon=100"

[root@localhost ~]# /etc/sysconfig/network-scripts/ifcfg-<interface name of primary slave> DEVICE=<interface name> HWADDR=xx.xx.xx.xx.xx.xx BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=no

4. 네트워크 관리

[root@localhost ~]# /etc/sysconfig/network-scripts/ifcfg-<<interface name of secondary slave> DEVICE=<interface name> HWADDR=xx.xx.xx.xx.xx.xx BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=no

RHEL7에서 /etc/modprobe.d/bonding.conf 는 작성할 필요 없습니다.

39

4.5. Network 설정 점검

4.5.1. NetworkManager 서비스 off, network 서비스 on

▼ network 서비스로 네트워크 구성할 경우 NetworkManager 서비스가 중지되어 있는지 확인

[root@localhost ~]# systemctl status NetworkManager * NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled; vendor preset: enabled) Active: inactive (dead)

▼ 만약 NetworkManager 서비스가 시스템 부팅 시 시작되도록 설정(enabled)되어 있다면 disable 설정

[root@localhost ~]# systemctl disable NetworkManager

▼ 시스템 부팅 시 NetworkManager 서비스가 시작되지 않도록 설정되어 있는지 확인 (RHEL6의 chkconfig --list와 유사)

[root@localhost ~]# systemctl list-unit-files -t service NetworkManager.service UNIT FILE STATE NetworkManager.service disabled

▼ network 서비스가 시스템 부팅 시 시작되도록 설정

[root@localhost ~]# chkconfig network on

▼ 설정 여부 확인

[root@localhost ~]# chkconfig --list network

▼ network 서비스 시작/중지/재시작/확인

[root@localhost ~]# service network start|stop|restart|status

4. 네트워크 관리

40

4.6. Network 동작 상태 점검

4.6.1. mac address 정보, 패킷 드랍 여부, 라우팅테이블 점검

4. 네트워크 관리

MRG-Realtime 2.1+과 RHEL7의 본딩 inactive slave에서 드랍 패킷 나타나는 이유는? Inactive slave in bond shows dropped packets on MRG-Realtime 2.1+ and RHEL7 https://access.redhat.com/solutions/295953

[root@localhost ~]# ethtool -s ens1f0 | grep -i drop rx_dropped: 0 tx_dropped: 0 rx_fcoe_dropped: 0 [root@localhost ~]# ethtool -s ens4f0 | grep -i drop rx_dropped: 178729 tx_dropped: 0 rx_fcoe_dropped: 0 [root@localhost ~]#

kernel -2.6.36부터 rx_dropped counter 설계 디자인이 변경된 관계로 본딩 inactive slave에서 드랍 패킷이 출력됩니다. 이는 실제 드랍된 패킷을 나타내는 것이 아니라 broadcast된 패킷이 rx_dropped 에 출력되는 것입니다. 따라서 무시해도 됩니다. rx_droppped가 확인되지 않는 일부 NIC 모듈의 경우 본딩 inactive slave 상태에서 rx_bcast_packets(수신 브로드캐스팅 패킷)의 카운트가 올라갈 것입니다. 역시 무시해도 되는 정보입니다.

41

5.1. Filesystem Overview 5. 스토리지 관리

5.1.1. RHEL7이 지원하는 파일시스템 정보

Specification Version 3 Version 4 Version 5 Version 6 Version 7 File systems and storage limits

Maximum filesize (Ext3) 2TB 2TB 2TB 2TB 2TB

Maximum file system size (Ext3) 2TB 8TB 16TB 16TB 16TB

Maximum subdirectories (Ext3) 32000 32000 32000 32000 32000 Maximum symlink depth (Ext3) 8 8 8 8 8

ACL support (Ext3) Yes Yes Yes Yes Yes

Maximum file size (Ext4) -- -- 16TB 16TB 16TB

Maximum subdirectories (Ext4) -- -- 65000/unlimited 65000/unlimited 65000/unlimited

Maximum symlink depth (Ext4) -- -- 8 8 8

ACL support (Ext4) -- -- Yes Yes Yes

Maximum file system size (Ext4) -- -- 16TB [1EB] 16TB [1EB] 50TB [1EB]

Maximum file size (GFS) 2TB 16TB [8EB] 16TB [8EB] N/A N/A

Maximum file system size (GFS) 2TB 16TB [8EB] 16TB [8EB] N/A N/A

Maximum file size (GFS2) -- -- 100TB [8EB] 100TB [8EB] 100TB [8EB]

Maximum file system size (GFS2) -- -- 100TB [8EB] 100TB [8EB] 100TB [8EB] Maximum file size (XFS) -- -- 100TB [8EB] 100TB [8EB] 500TB [8EB]

Maximum file system size (XFS) -- -- 100TB [16EB] 100TB [16EB] 500TB [16EB]

Maximum subdirectories (XFS) -- -- unlimited unlimited unlimited

Maximum symlink depth (XFS) -- -- 8 8 8

ACL support (XFS) N/A N/A Yes Yes Yes

Maximum Boot LUN size (BIOS) -- -- 2TB 2TB 2TB

Maximum Boot LUN size (UEFI) -- -- N/A 32bit (i686) - 2TB,

50TB 64bit - 16TB (tested limit)

Maximum x86 per-process virtual address space Approx. 4GB Approx. 4GB Approx. 3GB4 Approx. 3GB N/A

Maximum x86_64 per-process virtual address space 512GB 2TB 128TB 128TB

tested/supported [theoretical]

42

5.1.2. EXT4 및 XFS 명령 참조 표

작업 ext4 XFS

파일 시스템 생성 mkfs.ext4 mkfs.xfs

파일 시스템 마운트 mount mount

파일 시스템 크기 변경 resize2fs xfs_growfs

파일 시스템 복구 e2fsck xfs_repair

파일 시스템에 있는 레이블 변경 e2label xfs_admin -L

디스크 공간 및 파일 사용 보고 quota quota

파일 시스템 디버그 debugfs xfs_db

중요한 파일 시스템 메타데이터를 파일에 저장 e2image xfs_metadump

※ XFS 파일 시스템의 크기는 줄일 수 없습니다.

5. 스토리지 관리 5.1. Filesystem Overview

43

5.2. Fibre Channel SAN 기본 구성 및 관리

5.2.1. HBA 개요

HBA(Host Bus Adapter)는 Host system이나 server, storage, network 장치 간 I/O 프로세싱과 물리 연결을 제공하는 circuit board나 통합 circuit을 가리킵니다. 현업에서 HBA라 가리키는 대상은 주로 FC SAN 구간에서의 연결과 데이터 전송을 담당하는데 사용되는 Fibre Channel host bus adapter입니다.

5. 스토리지 관리

Fibre Channel host bus adapter로는 주로 Qlogic사와 Emulex사의 제품이 사용되고 있습니다. 레드햇 엔터프라이즈 리눅스의 커널은 두 제조사의 대부분의 HBA 모듈을 포함하고 있습니다.

Qlogic QLE2562 Dual Port Fibre Channel Host Bus Adapter Emulex LPE11002 FC 4GB 2-Port PCIe HBA Card

44

5.2. Fibre Channel SAN 기본 구성 및 관리 5. 스토리지 관리

(연결에 문제 있을 시 HBA port_state가 Linkdown 으로 나온다)

[root@localhost ~]# systool -c fc_host -v

(연결에 문제 있을 시 아무 정보도 출력되지 않을 수 있다)

[root@localhost ~]# systool -c fc_transport -v

SAN Switch와 스토리지 컨트롤러 간 연결 점검

HBA와 SAN Switch 간 연결 점검

systool 도구로 HBA, SAN스위치, 스토리지 벤더 전용 커맨드 없이도 FC SAN 구간별 점검을 직/간접적으로 할 수 있습니다. 문제가 발견되었을 경우 각 FC 장치의 벤더 엔지니어의 진단 및 조치가 필요합니다.

5.2.2. HBA와 스토리지 장치 간 연결 점검

45

5.2. Fibre Channel SAN 기본 구성 및 관리 5. 스토리지 관리

정보 설명

node_name the WWNN of the HBA port.

port_name the WWPN of the HBA port. (이 정보는 대개 SAN 스위치의 설정에 입력되는 값으로 이 설정을 통해 HBA와 SAN스위치 간 논리 연결이 이루어집니다)

port_state whether the port has a link or not

device symbolic link to the PCI bus device hierarchy in the /sys tree: use "ls -ld device" to see the PCI bus ID of the HBA port.

[root@localhost ~]# systool -c fc_host -v

/sys/class/fc_host 디렉토리는 각 FC port별로 "hostN"과 같은 이름이 부여된 단일 서브 디렉토리를 가질 것입니다. 각 서브 디렉토리에는 여러 파일이 있습니다. 이들은 읽기 편한 형태의 텍스트를 지니고 있습니다. cat 명령어로 볼 수 있습니다. HBA카드 식별, 연결 상태 체크를 위한 대부분의 유용한 정보들입니다.

5.2.2. HBA와 스토리지 장치 간 연결 점검

아래 명령어는 /sys/class/fc_host/ 정보를 출력합니다.

46

5.3. Multipathing

5.3.1. device-mapper-multipath 구성 및 점검

5. 스토리지 관리

RHEL은 MPIO(다중 경로 I/O)를 위해 device-mapper-multipath를 제공합니다. multipath 상태 모니터링은 multipath -ll 명령어로 합니다.

[root@iscsiinitiator ~]# multipath -ll mpathc (1IET_00010003) dm-4 IET ,VIRTUAL-DISK size=1.0G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active |- 33:0:0:3 sdf 8:80 active ready running `- 34:0:0:3 sdg 8:96 active ready running mpathb (1IET_00010002) dm-2 IET ,VIRTUAL-DISK size=1.0G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active |- 34:0:0:2 sde 8:64 active ready running `- 33:0:0:2 sdc 8:32 active ready running mpatha (1IET_00010001) dm-3 IET ,VIRTUAL-DISK size=1.0G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active |- 34:0:0:1 sdd 8:48 active ready running `- 33:0:0:1 sdb 8:16 active ready running [root@iscsiinitiator ~]#

dm device : 실제 사용하게 될 장치명으로 /dev/mapper/mpathN 형식의 장치명을 대상으로 볼륨 작업합니다. 이 매핑된 장치의 백엔드는 path based device입니다.

path based device name

멀티패스 경로의 상태

스토리지 LUN의 wwid로 변하지 않는 고유값

47

5.3.1. device-mapper-multipath 구성 및 점검

5. 스토리지 관리

device-mapper-multipath의 설정파일은 /etc/multipath.conf 입니다. 아래는 HITACHI OPEN-V 제품군의 스토리지에 연결된 RHEL7의 multipath.conf 의 예입니다.

defaults { user_friendly_names yes find_multipaths yes } blacklist { wwid 3600508b1001c2b3e2ecaf45ff6266c38 devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" devnode "^hd[a-z]" } devices { device { vendor "HITACHI " product "OPEN-V " path_grouping_policy multibus path_checker readsector0 path_selector "round-robin 0" hardware_handler "0" failback 15 rr_weight priorities no_path_retry queue } }

user_friendly_names : 사용자 친화적 이름을 쓸지 결정하는 옵션으로 yes(명시하지 않을 경우 yes가 기본값)의 경우 mpathN(/dev/mapper/mpathN), no의 경우 LUN wwid(/dev/mapper/<lun wwid>)로 매핑됩니다.

blacklist : 멀티패싱에서 제외할 장치의 wwid나 devnode를 명시. 주로 로컬디스크가 블랙리스트 대상이 되며 find_multipaths yes의 영향으로 대개 명시 불필요

device : 스토리지 벤더에서 제공하는 multipath.conf 를 1차적으로 참고하여 적용.

find_multipaths : 동일한 wwid를 가지면서 블랙리스트 선언되지 않은 다중 경로의 path based device가 확인되면 이를 dm device로 매핑하도록 할지 결정. (명시하지 않을 경우 기본값 yes) 이 옵션의 영향으로 대부분의 시스템 환경에서 블랙리스트 설정을 명시적으로 할 필요가 감소됨.

multipath.conf 샘플 /usr/share/doc/device-mapper-multipath-<version>/multipath.conf

5.3. Multipathing

48

5.3.1. device-mapper-multipath 구성 및 점검

5. 스토리지 관리

기본값으로 DM Multipath는 범용적인 설정값을 제공합니다. 추가적으로 DM Multipath를 자체 지원하는 대부분의 범용 스토리지 어레이의 지원 정보를 포함하고 있습니다. 지원되는 장치가 포함된 기본 설정값 정보를 보려면 아래 명령어 중 택일하여 실행합니다. multipath.conf에 적용할 수 있는 포맷으로 출력됩니다.

[root@localhost ~]# multipathd show config

[root@localhost ~]# multipath -t

5.3. Multipathing

49

5.4. Online storage reconfiguration

대부분의 경우, 시스템 온라인 상태에서 기존 볼륨을 제거하거나 신규 볼륨을 추가하는 작업이 필요할 것입니다.

① 물리머신에서 외장스토리지 LUN을 온라인 제거하는 방법

LUN 제거는 파일시스템의 데이터는 물론이며 LUN의 상위 layer에 분포한 dm-multipath 매핑, LVM 등의 각종 논리 정보도 제거됨을 의미하므로 이들의 사용 여부를 먼저 확인한 뒤 제거해야 합니다.

1IET_00020001

/dev/mapper/mpatha

/dev/mapper/mpatha

vgap01

1IET_00020002

/dev/mapper/mpathb

/dev/mapper/mpathb

1IET_00020003

/dev/mapper/mpathc

/dev/mapper/mpathc

centos redhat suse ubuntu

vgdb01

LUN

Device-mapper-multipath

Physical Volume

Volume Group

Logical Volume

sdb Path based device sdd sdc sdf sde sdg

xfs xfs xfs xfs File System

raw0 raw2

raw0 raw1 Raw Device

5. 스토리지 관리

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

50

LUN의 ID는 스토리지 벤더에서 제공하는 도구 없이 RHEL7에서 제공하는 명령어로도 확인 가능합니다.

1IET_00020001 1IET_00020002 1IET_00020003 LUN

sdb Path based device sdd sdc sdf sde sdg

dual 멀티패스 환경에서 하나의 LUN은 2개의 path based device name(경로 기반 장치명)으로 보이게 됩니다.

[root@localhost ~]# /usr/lib/udev/scsi_id -gud <path based device>

형식)

[root@localhost ~]# /usr/lib/udev/scsi_id -gud /dev/sdb 1IET_00020001 [root@localhost ~]# /usr/lib/udev/scsi_id -gud /dev/sdd 1IET_00020001

예)

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

51

LVM physical volume은 mpath 장치를 대상으로 만들고 관리되어야 합니다.

[root@localhost ~]# multipath -ll mpathc (1IET_00020003) dm-4 IET ,VIRTUAL-DISK size=2.0G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active |- 3:0:0:3 sdg 8:96 active ready running `- 4:0:0:3 sde 8:64 active ready running mpathb (1IET_00020002) dm-3 IET ,VIRTUAL-DISK size=2.0G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active |- 3:0:0:2 sdf 8:80 active ready running `- 4:0:0:2 sdc 8:32 active ready running mpatha (1IET_00020001) dm-2 IET ,VIRTUAL-DISK size=2.0G features='0' hwhandler='0' wp=rw `-+- policy='service-time 0' prio=1 status=active |- 3:0:0:1 sdd 8:48 active ready running `- 4:0:0:1 sdb 8:16 active ready running

1IET_00020001

/dev/mapper/mpatha

1IET_00020002

/dev/mapper/mpathb

1IET_00020003

/dev/mapper/mpathc

LUN

Device-mapper-multipath

sdb Path based device sdd sdc sdf sde sdg

/dev/mapper/mpatha /dev/mapper/mpathb /dev/mapper/mpathc Physical Volume

[root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/mapper/mpatha vgap01 lvm2 a-- 2.00g 0 /dev/mapper/mpathb vgap01 lvm2 a-- 2.00g 0 /dev/mapper/mpathc vgdb01 lvm2 a-- 2.00g 0 /dev/sda2 vg00 lvm2 a-- 29.00g 0

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

52

1IET_00020001

/dev/mapper/mpatha

/dev/mapper/mpatha

vgap01

1IET_00020002

/dev/mapper/mpathb

/dev/mapper/mpathb

centos redhat suse ubuntu

sdb sdd sdc sdf

xfs xfs xfs xfs

[root@localhost ~]# lvremove /dev/vgap01/centos [root@localhost ~]# lvremove /dev/vgap01/redhat [root@localhost ~]# lvremove /dev/vgap01/suse [root@localhost ~]# lvremove /dev/vgap01/ubuntu

logical volume 제거

[root@localhost ~]# vgremove vgap01

volume group 제거

[root@localhost ~]# pvremove /dev/mapper/mpatha [root@localhost ~]# pvremove /dev/mapper/mpathb

physical volume 제거

[root@localhost ~]# multipath -f mpatha ; multipath -f mpathb

제거할 multipath device의 map을 flush(shared volume의 경우 다른 서버에서도 같이 작업)

[root@localhost ~]# vgchange -an vgap01

shared volume의 경우 LVM 작업을 직접 하지 않을 서버에서 LVM 속성을 deactivate

[root@localhost ~]# echo 1 > /sys/block/sdb/device/delete ; echo 1 > /sys/block/sdd/device/delete \ echo 1 > /sys/block/sdc/device/delete ; echo 1 > /sys/block/sdf/device/delete

LUN 제거(shared volume의 경우 다른 서버에서도 같이 작업)

XFS 파일시스템 영역을 온라인 제거하는 절차를 설명합니다. 파일시스템 unmount 상태에서 작업해야 합니다.

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

53

[root@localhost ~]# raw /dev/raw/raw1 0 0 [root@localhost ~]# raw /dev/raw/raw2 0 0

raw device unmapping(shared volume을 쓰는 모든 서버에서 수행)

Oracle용 raw device 영역을 온라인 제거하는 절차를 설명합니다.

1IET_00020003

/dev/mapper/mpathc

/dev/mapper/mpathc

vgdb01

sde sdg

raw1 raw2

raw1 raw2

이후는 앞 페이지의 LVM -> multipath -> LUN 순서와 동일하게 제거

[root@localhost ~]# vgchange -an vgap01

shared volume의 경우 LVM 작업을 직접 하지 않을 서버에서 LVM 속성을 deactivate

[root@localhost ~]# vi /etc/udev/rules.d/60-raw.rules ACTION=="add|change", ENV{DM_VG_NAME}=="vgdb01", ENV{DM_LV_NAME}=="raw1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add|change", ENV{DM_VG_NAME}=="vgdb01", ENV{DM_LV_NAME}=="raw2", RUN+="/bin/raw /dev/raw/raw2 %N" ACTION=="add|change", KERNEL=="raw*", OWNER="oracle", GROUP="dba", MODE="0660"

시스템 재부팅 시에도 mapping되지 않도록 /etc/udev/rules.d/60-raw.rules에서 영구 삭제

삭제

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

54

5.4. Online storage reconfiguration

외장 스토리지에서 RHEL에 할당한 신규 LUN을 RHEL에 온라인으로 인식시키는 명령어는 여러 가지이므로 아무 것이나 선택 사용하면 됩니다. 외장 스토리지 뿐만 아니라 핫플러깅을 지원하는 SCSI 호환 디바이스를 대상으로 가능한 방법입니다.

sg3_utils 패키지가 설치되어 있을 경우 스크립트로 편리하게 실행 가능합니다.

[root@localhost ~]# rpm -qa sg3_utils sg3_utils-1.37-5.el7.x86_64

[root@localhost ~]# rescan-scsi-bus.sh

<기존 스토리지 박스>의 신규 LUN을 인식시킬 때

스크립트 명령어

[root@localhost ~]# for host in $(ls /sys/class/scsi_host) ; do echo - - - > /sys/class/scsi_host/$host/scan ; done

일반 명령어

[root@localhost ~]# rescan-scsi-bus.sh --issue-lip

<신규 스토리지 박스>의 신규 LUN을 인식시킬 때

스크립트 명령어

[root@localhost ~]# for host in $(ls /sys/class/fc_host) ; do echo 1 > /sys/class/fc_host/$host/issue_lip ; done

일반 명령어

5. 스토리지 관리

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

55

컴퓨터 재부팅 없이 SCSI 장치를 추가하고 제거하기 위해 SCSI bus를 어떻게 재탐색하는가? How to rescan the SCSI bus to add or remove a SCSI device without rebooting the computer https://access.redhat.com/site/solutions/3941

환경 Red Hat Enterprise Linux 5.0 or above

SCSI devices over a Fibre Channel or iSCSI transport 온라인 스토리지 재구성을 위한 기술지원은 RHEL5과 이후 버전들에서 제공됩니다. 스토리지 hot adding과 removing을 위한 제한된 도구들이 있으나, 모든 구성에서 올바르게 작동함을 보증할 수 없습니다. RHEL5는 온라인 스토리지 재구성을 위한 포괄적 지원을 허용하는, udev, low level 디바이스 드라이버, SCSI 미드레이어, 디바이스 매퍼 멀티패스로의 많은 기능강화를 포함합니다.

문제 Is it possible to add or remove a SCSI device without rebooting a running system?

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

56

해결 Removing a Storage Device 스토리지 디바이스 자체로 향하는 접근을 제거하기 전에, 여러분은 장치로부터 데이터를 복사하기 원할 것입니다. 데이터 복사를 원할 때, 아래에서 설명하는 대로 여러분은 모든 I/O를 stop하고 flush하여야 하며, 디바이스로 향하는 모든 운영체제 레퍼런스를 제거해야 합니다. 만약 이것이 멀티패스 장치라면 여러분은 이를 멀티패스 의사 장치, 그리고 장치로 향하는 경로를 대표하는 각 식별자를 위하여 해야 합니다. 스토리지 장치 제거는 시스템이 메모리 pressure 상태일 때에는 권장되지 않습니다. 이후 I/O flush가 load를 증가시킬 것입니다. 메모리 pressure 레벨을 결정하기 위하여 아래 명령어를 수행하십시오. 장치 명령어는 swapping이 active(vmstat 출력에서 non-zero “si”그리고 “so”column), 그리고 100회 중 10회 샘플보다 더 많은 데에서 free memory가 total memory의 5% 미만일 때는 권장되지 않습니다.(total memory는 “free” 명령어로 확인 가능합니다)

vmstat 1 100

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

57

해결 장치로 향하는 모든 접근을 제거하는 일반적인 순서는 다음과 같습니다: 1. 모든 장치 사용자를 닫습니다. 필요 시 장치로부터 데이터를 복사합니다. 2. 장치를 마운트했던 파일시스템을 언마운트하기 위해 umount를 사용합니다. 3. 장치를 사용 중인 md와 LVM 볼륨으로부터 장치를 제거하십시오. 만약 장치가 LVM 볼륨 그룹의 멤버라면, pvmove 명령어를 사용하여 데이터를 이동시킬 필요가 있을 수 있습니다. 그리고나서 물리 볼륨을 제거하기 위해 vgreduce 명령을 사용하고, (선택적으로) 디스크로부터 LVM 메타데이터를 제거하기 위해 pvremove를 사용하십시오. 4. 만약 여러분이 멀티패스 장치를 제거 중이라면, multipath –l을 실행하고 장치로 향하는 모든 경로를 기록하십시오. multipath-device는 예를 들어 멀티패스 장치 mpath10의 이름입니다. NOTE: 만약 멀티패스 장치가 여전히 사용 중일 때(예를 들어, 파티션이 장치에 있는 상태), “map in use”와 함께 이 명령어는 실패합니다. 추가사항 확인 위해 아래 링크 확인하십시오. How to get rid of or remove the multipath device without rebooting the server, rescanning the scsi bus, or restarting multipathd 5. 장치로 향하는 모든 경로로 드러나는 I/O를 flush시키기 위해 아래 명령어를 사용하십시오: 이는 I/O flush를 유발하는 unmount나 vgreduce 작동이 없는 raw device를 위해 특히 중요합니다.

multipath –f multipath-device

blockdev --flushbufs device

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

58

해결 6. 시스템 상의 어플리케이션, 스크립트, 유틸리티에서 /dev/sd 또는 /dev/disk/by-path, major:minor number와 같은 장치의 경로 기반

이름(path-based name)으로 향하는 레퍼런스를 제거하십시오. 이는 다른 장치가 미래에 추가될 때 현재 장치를 위해 실수하지 않을 것임을 보증하기 위하여 중요합니다. 7. 마지막 절차는 SCSI 서브시스템으로부터 장치로 향하는 각 경로를 제거하는 것입니다. 경로를 제거하는 그 명령어는: 예를 들어, device-name은 sde가 될 수 있습니다. 이 동작의 또다른 변형은: h는 HBA 숫자, c는 HBA 채널, t는 SCSI target ID, 그리고 l은 LUN입니다. 여러분은 lsscsi, scsi_id, multipath –l, ls –l /dev/disk/by-*와 같은, 다양한 명령어로부터 장치를 위한 device-name과 h, c, t, l을 결정할 수 있습니다. 삭제될 장치가 scsi generic 특수 파일 이름으로 알려져 있을 때 이 동작의 또다른 변형은:

echo 1 > /sys/block/device-name/device/delete

echo 1 > /sys/class/scsi_device/h:c:t:l/device/delete

echo 1 > /sys/class/scsi_generic/sg-name/device/delete

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

59

해결 Adding a Storage Device or a Path

시스템이 신규 장치에 할당한 경로 기반 장치명 (예를 들어,“sd”이름, major:minor 숫자, /dev/disk/by-path 이름) 이 그 이래에 삭제된 장치에 의해 이전에 사용 상태일 수도 있음을 인지하십시오. 그렇지 않으면 신규 장치는 이전 장치와 혼동될 수 있습니다.

첫 번째 절차는 신규 스토리지 장치를 향한 접근이나 존재하는 장치를 향한 신규 경로를 물리적으로 활성화하는 것입니다. 이에는 FC나 iSCSI 스토리지의 케이블, 디스크, 벤더 전용 명령어 설치가 해당될 수 있습니다. 여러분이 이것을 할 때, 여러분의 host에 존재할 신규 스토리지 를 위한 LUN 값을 기록해 두십시오.

다음, 운영체제가 신규 스토리지 장치나 존재하는 장치의 경로를 인식할 수 있도록 하십시오. 명령어로는: H는 HBA number, c는 HBA 채널,, t는 SCSI target ID, l은 LUN입니다. sdN 이름과 scsi h:c:t:l address 간 scsi h:c:t:l addressing 과 mapping 에 관한 정보를 위하여 How do you map between scsi address <0 0 0 0> (or 0:0:0:0) and scsi device name (sda)? 를 확인하십시오. RHEL 5.6부터는 c, t, l을 표시한 위치에 와일드카드 문자인 “-”로 대체 가능합니다. 이 경우, 이 명령어 실행하는 동안 I/O 중지는 필수적이지 않습니다. 5.6 버전 이전에는, 이 명령어와 함께 사용 시의 와일드카드 문자 사용은 주의사항으로 I/O 일시정지를 요구했습니다.

echo "c t l" > /sys/class/scsi_host/hostH/scan

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

60

리부팅 없이 SCSI 장치를 위한 HP Smart Array를 어떻게 재탐색하는가? How do I rescan an HP Smart Array for new SCSI devices without rebooting? https://access.redhat.com/site/solutions/7832

환경 Red Hat Enterprise Linux 5 or above

HP Smart Array controller

cciss module

문제 How to rescan an HP Smart Array for new SCSI devices without rebooting?

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

61

해결 HP Smart Array 컨트롤러는 cciss 드라이버를 사용합니다. 이 드라이버는 디스크나 어레이 디바이스를 Linux SCSI 서브시스템에 표시하지 않으며 사용자는 신규 디스크 또는 디스크 어레이를 구성하고 활성화하기 위한 벤더 제공 관리 도구를 사용해야 합니다.

테이프 디바이스, meida changers, 다른 시리얼 디바이스들을 위하여, CCISS 컨트롤러는 SCSI 서브시스템과 함께 장치들을 등록할 것입니다. 신규 테이프 또는 medium changers가 실행 상태의 시스템에 추가되면, 그들은 CCISS scsi bus가 재탐색될 때까지는 시스템에서 확인되지 않을 것입니다. 이는 reboot으로 자동 일어납니다. Reboot이 불가능하거나 바람직하다면, 아래 명령어를 사용할 수 있습니다. 첫째, cciss 드라이버에 SCSI bus를 대상으로 한 변경에 관해 통보하기 위해 재탐색이 이뤄집니다:

그런 다음, 개개의 장치들을 아래 명령어로 추가하십시오.

위의 예는 controller 3, bus 2, target 1, lun 0 에 장치를 추가합니다. 추가된 장치의 위치와 세팅에 따라 값을 변경하십시오.

이 동작은 CCISS 컨트롤러를 통해 시스템에 제공되는 디스크나 레이드 어레이에 영향을 미치지 않음을 알아두는 것이 중요합니다.

$ echo "rescan" > /proc/driver/cciss/cciss0

$ echo scsi add-single-device 3 2 1 0 > /proc/scsi/scsi

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.1. 물리머신에서 외장스토리지 LUN을 온라인 제거 및 추가

62

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.2. RHEL7에 Oracle ASM disks (raw devices) 생성 및 제거

Backing device type

udev rule 파일 경로 udev rule 작성 방법

DM Multipath devices

/etc/udev/rules.d/96-asmmultipath.rules

ACTION=="add|change", ENV{DM_UUID}=="mpath-<UUID>", SYMLINK+="oracleasm/asm01", GROUP="dba", OWNER="oracle", MODE="0660" ※ DM_UUID 확인 방법 $ udevadm info --query=all --name=/dev/mapper/mpathN |grep -i DM_UUID

LVM /etc/udev/rules.d/60-raw.rules

ACTION!="add|change", GOTO="raw_end" # Create raw character device mapping (Replace vg_test and lv_test with your volume names) ENV{DM_VG_NAME}=="vg_test", ENV{DM_LV_NAME}=="lv_test1", RUN+="/bin/raw /dev/raw/raw1 %N“ ENV{DM_VG_NAME}=="vg_test", ENV{DM_LV_NAME}=="lv_test2", RUN+="/bin/raw /dev/raw/raw2 %N" # To set permissions: KERNEL=="raw*", OWNER:="testuser", GROUP:="testuser", MODE:="0660" LABEL="raw_end"

rule 파일을 작성하였으면 온라인 인식 위해 udev rules을 reload합니다. /dev/raw/rawN 장치들이 확인될 것입니다.

[root@localhost ~]# udevadm control --reload-rules [root@localhost ~]# udevadm trigger --type=devices --action=change

① 생성

63

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.2. RHEL7에 Oracle ASM disks (raw devices) 생성 및 제거

② 삭제

[root@localhost ~]# raw /dev/raw/rawN 0 0

Step 1) raw device unmapping

[root@localhost ~]# vi /etc/udev/rules.d/60-raw.rules ACTION=="add|change", ENV{DM_VG_NAME}=="vgdb01", ENV{DM_LV_NAME}=="raw1", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add|change", ENV{DM_VG_NAME}=="vgdb01", ENV{DM_LV_NAME}=="raw2", RUN+="/bin/raw /dev/raw/raw2 %N" ACTION=="add|change", KERNEL=="raw*", OWNER="oracle", GROUP="dba", MODE="0660"

Step 2) 시스템 재부팅 시에도 mapping되지 않도록 rules 파일에서 영구 삭제

삭제

64

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.3. Filesystem over LVM 을 resizing하기

① 논리볼륨 확장

확장의 경우 Filesystem over LVM을 umount 필요없이 온라인 작업 가능합니다.

Step 1) 논리볼륨 리사이징

아래 두 가지 방법의 예 중에서 택일하십시오. /dev/vg00/lv00 논리볼륨의 용량을 12G로 확장하기(확장되어 나온 볼륨의 용량이 12G여야 하는 경우)

# lvextend -L 12G /dev/vg00/lv00

/dev/vg00/lv00 논리볼륨의 용량을 +12G로 확장하기(확장되어 나온 볼륨의 용량이 기존 대비 +12G여야 하는 경우)

# lvextend -L +12G /dev/vg00/lv00

Step 2) 파일시스템 리사이징

# lvextend -L +12G /dev/vg00/lv00

ext4

# xfs_growfs /dev/vg00/lv00 [ -D size ]

xfs

-D size 옵션은 파일시스템을 지정된 사이즈로 확장합니다. 없으면 최대치(장치 사이즈)로 확장합니다.

65

5. 스토리지 관리 5.4. Online storage reconfiguration

5.4.3. Filesystem over LVM 을 resizing하기

② 논리볼륨 축소

축소의 경우 umount하여 작업하여야 하며, 데이터 무결성을 보증해 주지 않으므로 데이터를 다른 볼륨에 반드시 백업한 뒤 작업하시기 바랍니다. 확장 작업 과정의 역순으로 작업합니다.

XFS 파일 시스템의 크기는 줄일 수 없습니다.

# umount /dev/vg00/lv00 # e2fsck -f [ -y ] /dev/vg00/lv00

# resize2fs [ –f ] /dev/vg00/lv00 5G

Step 1) ext4 파일시스템 umount 및 파일시스템 메타데이터 consistency 검사(e2fsck는 xfs를 대상으로 사용할 수 없습니다)

Step 2) 파일시스템을 리사이징 파일시스템 사이즈를 5G로 축소(변경)

Step 3) 논리볼륨 리사이징 /dev/vg00/lv00 논리볼륨의 용량을 5G로 축소하기(축소되어 나온 볼륨의 용량이 5G여야 하는 경우)

# lvreduce -L 5G /dev/vg00/lv00

66

5.5. 작동 상태 점검

5.5.1. 파일시스템 mount 상태 확인

[root@localhost ~]# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,size=1924664k,nr_inodes=481166,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) configfs on /sys/kernel/config type configfs (rw,relatime) /dev/mapper/rhel-root on / type xfs (rw,relatime,attr2,inode64,noquota) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) mqueue on /dev/mqueue type mqueue (rw,relatime) debugfs on /sys/kernel/debug type debugfs (rw,relatime) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime) nfsd on /proc/fs/nfsd type nfsd (rw,relatime) /dev/vda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=387872k,mode=700,uid=1000,gid=1000) tmpfs on /run/user/42 type tmpfs (rw,nosuid,nodev,relatime,size=387872k,mode=700,uid=42,gid=42) fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime) tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=387872k,mode=700) gvfsd-fuse on /run/user/0/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0)

5. 스토리지 관리

67

5.5. 작동 상태 점검

5.5.1. 파일시스템 mount 상태 확인

mount 명령어로 파일시스템 마운트 상태 확인 가능하며 파일시스템 metadata consistency에 문제 생긴 경우 데이터 보호를 위해 커널은 해당 파일시스템을 read-only로 변경

[root@localhost ~]# mount (생략) /dev/mapper/rhel-root on / type xfs (rw,relatime,attr2,inode64,noquota) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) mqueue on /dev/mqueue type mqueue (rw,relatime) debugfs on /sys/kernel/debug type debugfs (rw,relatime) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime) nfsd on /proc/fs/nfsd type nfsd (rw,relatime) /dev/vda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota (생략)

물리적/논리적 문제가 아닌 단순 사용자 부주의로 인한 read-only 마운트 장치가 확인되었을 시 rw로 재마운트하면 된다. mount –o remount,rw <device name>

5. 스토리지 관리

68

5.5.2. /proc/partitions 확인

[root@localhost ~]# cat /proc/partitions major minor #blocks name 252 0 31457280 vda 252 1 512000 vda1 252 2 30944256 vda2 252 16 31457280 vdb 11 0 1048575 sr0 253 0 28798976 dm-0 253 1 2097152 dm-1 [root@localhost ~]#

5. 스토리지 관리 5.5. 작동 상태 점검

69

6.1. kexec-tools 설치 및 구성

6. crash dump 관리

6.1.1. kdump 개요

kdump란? kdump 는 커널 crash 가 일어났을 때 메모리 덤프를 해주는 역할로 구 버전의 diskdump와 netdump가 kexec와 kdump로 대체되었습니다. kdump에서는 raw device, disk partition, nfs, ssh 등을 지원합니다.

kexec / kdump 1) kexec 의 역할 kexec는 새로운 커널이 BIOS를 통하지 않고 재부팅이 될 수 있게 해 줍니다. kexec는 부팅시에 메모리에(RAM)에 상주하게 되며 패닉(panic) 발생 시 현재 커널을 정지 시키고 새로운 커널(dump용 커널)을 동작시키는 역할을 합니다.

[root@localhost ~]# ls -l /boot/ total 93232 -rw-r--r--. 1 root root 126426 Oct 30 06:32 config-3.10.0-327.el7.x86_64 drwx------. 6 root root 104 Mar 16 14:09 grub2 -rw-r--r--. 1 root root 43589175 Mar 16 12:11 initramfs-0-rescue-4e4c698d9ff1471d827143201a081091.img -rw-------. 1 root root 19665722 Mar 16 12:16 initramfs-3.10.0-327.el7.x86_64.img -rw------- 1 root root 17945621 Mar 16 12:44 initramfs-3.10.0-327.el7.x86_64kdump.img -rw-r--r--. 1 root root 601724 Mar 16 12:02 initrd-plymouth.img -rw-r--r--. 1 root root 252612 Oct 30 06:35 symvers-3.10.0-327.el7.x86_64.gz -rw-------. 1 root root 2963044 Oct 30 06:32 System.map-3.10.0-327.el7.x86_64 -rwxr-xr-x. 1 root root 5154912 Mar 16 12:14 vmlinuz-0-rescue-4e4c698d9ff1471d827143201a081091 -rwxr-xr-x. 1 root root 5154912 Oct 30 06:32 vmlinuz-3.10.0-327.el7.x86_64 [root@localhost ~]#

2) kdump의 역할 /etc/kdump.conf 환경설정 파일을 가지고 있으며, 서버의 panic 상황을 지켜보는 역할을 합니다.

crash 발생 시 재부팅될 때 사용되는 비상 커널 이미지 파일

70

6.1.2. GRUB2 에 crashkernel 파라미터 설정 여부 확인

[root@localhost ~]# grubby --info /boot/vmlinuz-3.10.0-327.el7.x86_64 index=0 kernel=/boot/vmlinuz-3.10.0-327.el7.x86_64 args="ro crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap" root=/dev/mapper/rhel-root initrd=/boot/initramfs-3.10.0-327.el7.x86_64.img title=Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo) [root@localhost ~]#

GRUB2 설정에 crashkernel 파라미터가 있는지 확인

[root@localhost ~]# vi /boot/grub2/grub.cfg GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap" GRUB_DISABLE_RECOVERY="true" [root@localhost ~]# grub2-mkconfig –o /boot/grub/grub [root@localhost ~]# shutdown –r now

없다면 추가하고 재부팅하여 반영

6. crash dump 관리 6.1. kexec-tools 설치 및 구성

71

6.1.3. /etc/kdump.conf 설정

[root@localhost ~]# yum install kexec-tools [root@localhost ~]# cat /etc/kdump.conf (생략) #raw /dev/vg/lv_kdump #ext4 /dev/vg/lv_kdump #ext4 LABEL=/boot #ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937 #nfs my.server.com:/export/tmp #ssh [email protected] #sshkey /root/.ssh/kdump_id_rsa path /var/crash core_collector makedumpfile -l --message-level 1 -d 31 #core_collector scp #kdump_post /var/crash/scripts/kdump-post.sh #kdump_pre /var/crash/scripts/kdump-pre.sh #extra_bins /usr/bin/lftp #extra_modules gfs2 #default shell #force_rebuild 1 #dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" #fence_kdump_args -p 7410 -f auto -c 0 -i 10 #fence_kdump_nodes node1 node2

/etc/kdump.conf는 /var/crash 용량만 물리메모리보다 많이 확보(+1% 권장)되어 있다면 기본 설정값 그대로 사용 권장

nfs나 scp를 통해 원격서버에 crash dump 저장 가능

기본값으로 /var/crash에 저장

kdump 구성 참고 문서 (RHEL7.2 기준) /usr/share/doc/kexec-tools-2.0.7/kexec-kdump-howto.txt

6. crash dump 관리 6.1. kexec-tools 설치 및 구성

72

6.2.1. kdump 실행 및 테스트

[root@localhost ~]# systemctl enable kdump [root@localhost ~]# systemctl start kdump

커널 패닉 유발 테스트 방법 ① sysrq(System Request) 설정 여부 확인 (/usr/lib/sysctl.d/50-default.conf 에 kernel.sysrq = 16 기본값으로 설정되어 있음) ② 키보드에서 Alt + sysRq + c (Magic SysRq)키를 동시에 눌러서 패닉 유발 ③ echo c > /proc/sysrq-trigger 명령어를 통해서 패닉 유발

[root@localhost ~]# sysctl -a | grep sysrq kernel.sysrq = 16

6. crash dump 관리 6.2. kexec-tools 동작 점검

73

6.2.2. Hang Up에 대비한 nmi_watchdog 설정

무한루프나 데드락(dead lock)이 발생해 아무런 메시지도 출력하지 않고 키보드 입력 또한 할 수 없을 때가 있다. 이런 상황에서는 Magic SysRq 키를 이용하면 쉽게 디버깅할 수 있다. 하지만 모든 CPU의 인터럽트가 금지돼 커널이 프리즈(freeze)되면 Magic SysRq 키를 이용할 수 없다. 이런 상황에서는 NMI watchdog을 이용해 덤프(dump)를 얻을 수 있다.

부팅 시 커널의 parameter로 "nmi_watchdog=1" 을 전달하면, 부팅 후 /proc/interrupts 라는 파일의 내용 중 NMI 라는 값이 모든 CPU별로 계속 증가한다. 한 개의 CPU라도 NMI 값이 증가하지 않는 현상이 발생하면, 커널은 자기 자신을 Crash 시킨다. 이를 통해서 Netdump/Diskdump/Kdump로 Memory Dump 를 받을 수 있다. 단, nmi_watchdog 의 경우 smp 커널에서만 동작한다. 물리적으로 Single CPU일지라도 Hyperthreading 을 사용해서 SMP 기능을 사용하고 있는 경우에도 가능하다.

6. crash dump 관리 6.2. kexec-tools 동작 점검

74

6.2.2. Hang Up에 대비한 nmi_watchdog 설정

방법 적용 방법 장애 시 조치 방법

1. OS의 nmi_watchdog 사용

kernel boot option에 “nmi_watchdog = <0|1|2>” 설정 적용 H/W에 따라 "1" 또는 "2"를 적용, H/W에서 nmi_capture signal에 따라서 변경해서 사용해야 하는 부분이기 때문에 테스트 후 적용 가능한 옵션 찾기

별다른 조치 불필요. OS에서 자체적으로 nmi 시그널 발생시킴.

2. 하드웨어 nmi_watchdog 스위치 사용

kernel boot option에 “nmi_watchdog = <0|1|2>” 설정 적용 H/W에 따라 "1" 또는 "2"를 적용, H/W에서 nmi_capture signal에 따라서 변경해서 사용해야 하는 부분이기 때문에 테스트 후 적용 가능한 옵션 찾기 /etc/sysctl.conf에 “kernel.unknown_nmi_panic = 1 “설정

NMI LED

뾰족한 클립 등을 이용하여 눌러준다

6. crash dump 관리 6.2. kexec-tools 동작 점검

75

감사합니다 문의 : [email protected]

76

Open

Share

Contribute

Adopt

Reuse