본문 바로가기
공부/Linux

Linux 8.x KVM Install

by CITTA 2024. 1. 2.
728x90
반응형

RHEL 8.9 KVM Install

1. 명령어를 통해 가상화를 지원하는 환경인지 확인합니다.

## Intel 기반은 아래 명령어를 사용
# grep -e 'vmx' /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves arat umip pku ospke gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear flush_l1d arch_capabilities
...
또는 
## AMD 기반은 아래 명령어를 사용
# grep -e 'svm' /proc/cpuinfo

## KVM 모듈 확인 (기본적으로 로드 되어있어야 함)
# lsmod |grep kvm
kvm_intel             344064  0
kvm                   962560  1 kvm_intel
irqbypass              16384  1 kvm
# ls -l /dev/kvm
crw-rw-rw-. 1 root kvm 10, 232 Jan  2 13:17 /dev/kvm

# lscpu |grep Virtualization
Virtualization:      VT-x
Virtualization type: full

 

2. VM 생성 및 관리를 위한 QEMU 설치

  • GUI 환경이 아닐 경우 필요 시 GUI 환경 설치하면 됩니다.
# dnf install qemu-kvm libvirt virt-install virt-manager

## virt-host-validate 명령을 동해 host system이 libvirt 하이퍼바이저 드라이버를 실행하도록 설정되었는지 확인
# virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : PASS
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : PASS
  QEMU: Checking for cgroup 'blkio' controller support                       : PASS
  QEMU: Checking for device assignment IOMMU support                         : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)
  QEMU: Checking for secure guest support                                    : WARN (Unknown if this platform has Secure Guest support)
# systemctl enable --now libvirtd.service

 

3. cockpit 활성화 및 확인

# systemctl start cockpit.socket
# systemctl enable cockpit.socket
Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket → /usr/lib/systemd/system/cockpit.socket.
# systemctl status cockpit.socket
● cockpit.socket - Cockpit Web Service Socket
   Loaded: loaded (/usr/lib/systemd/system/cockpit.socket; enabled; vendor preset: disabled)
   Active: active (listening) since Tue 2024-01-02 14:02:03 KST; 14s ago
     Docs: man:cockpit-ws(8)
   Listen: [::]:9090 (Stream)
    Tasks: 0 (limit: 408230)
   Memory: 80.0K
   CGroup: /system.slice/cockpit.socket

Jan 02 14:02:03 citta-rhel89 systemd[1]: Starting Cockpit Web Service Socket.
Jan 02 14:02:03 citta-rhel89 systemd[1]: Listening on Cockpit Web Service Socket.

# firewall-cmd --add-service=cockpit --permanent
Warning: ALREADY_ENABLED: cockpit
success

 

# firewall-cmd --reload
success

 

4. web 접속 확인

 

5. Bridge 네트워크 설정

  • cli 설정
## cli
# nmcli c
NAME    UUID                                  TYPE      DEVICE
ens160  5d2147e2-e143-433c-87b3-2e574d325d24  ethernet  ens160
virbr0  01747e1a-b31d-40de-8351-79f50fd71f85  bridge    virbr0
# nmcli c a type bridge con-name br0 ifname br0
Connection 'br0' (d4486cfc-f97d-4e6a-b084-23ed12d09a62) successfully added.
# nmcli c m br0 ipv4.method manual ipv4.address 192.168.45.120/24 ipv4.gateway 192.168.45.1 autoconnect yes
# nmcli c m ens160 connection.slave-type bridge master br0 autoconnect yes
# nmcli c u ens160; nmcli c u br0
# nmcli c
NAME    UUID                                  TYPE      DEVICE
br0     d4486cfc-f97d-4e6a-b084-23ed12d09a62  bridge    br0
virbr0  01747e1a-b31d-40de-8351-79f50fd71f85  bridge    virbr0
ens160  5d2147e2-e143-433c-87b3-2e574d325d24  ethernet  ens160
  • cockpit 설정 (Networking → Add bridge)

  • 사용할 기존 네트워크 인터페이스 선택 및 이름 설정 → Add

 

6. SSH 원격 접속을 통해 virt-manager를 이용하고 싶을 경우

## X11Forwarding 설정값을 yes 로 설정
# vi /etc/ssh/sshd_config
...
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
**X11Forwarding yes**
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
...
# systemctl restart sshd

## 해당 패키지 설치가 안됐을 경우
# dnf install xterm xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils
728x90
반응형

댓글