티스토리 뷰

___리눅스

[리눅스] CentOS 7에 KVM 하이퍼바이저 설치

변군 변군이글루 2020. 11. 18. 23:20

CentOS 7에 KVM 하이퍼바이저 설치

 

테스트 환경

$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)

$ getconf LONG_BIT
64

$ uname -a
Linux ntvm-peer01 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

 

가상화 지원 여부 확인

$ grep -E '(vmx|svm)' /proc/cpuinfo

 

KVM 관련 패키지 설치

$ yum install -y libvirt qemu-kvm virt-install virt-manager

**의존성 관련하여 125개 정도의 패키지 업데이트되거나 추가로 설치된다.

 

libvirt 서비스 활성화

$ systemctl --now enable libvirtd


$ systemctl status libvirtd
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-11-18 21:57:24 KST; 13s ago
     Docs: man:libvirtd(8)
           https://libvirt.org
 Main PID: 9190 (libvirtd)
    Tasks: 19 (limit: 32768)
   CGroup: /system.slice/libvirtd.service
           ├─9190 /usr/sbin/libvirtd
           ├─9289 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/li...
           └─9290 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/li...

Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: started, version 2.76 cachesize 150
Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua...notify
Nov 18 21:57:24 ntvm-peer01 dnsmasq-dhcp[9289]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Nov 18 21:57:24 ntvm-peer01 dnsmasq-dhcp[9289]: DHCP, sockets bound exclusively to interface virbr0
Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: reading /etc/resolv.conf
Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: using nameserver 1.1.1.1#53
Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: using nameserver 8.8.8.8#53
Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: read /etc/hosts - 2 addresses
Nov 18 21:57:24 ntvm-peer01 dnsmasq[9289]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Nov 18 21:57:24 ntvm-peer01 dnsmasq-dhcp[9289]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Hint: Some lines were ellipsized, use -l to show in full.

 

bridge 네트워크 설정

ifcfg-br0 생성

$ vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.255.255.241
NETMASK=255.255.255.0
GATEWAY=10.255.255.1

 

ifcfg-enp0s3 편집(기존 인터페이스)

$ vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
HWADDR=08:00:27:76:a7:2e
DEVICE=enp0s3
ONBOOT=yes
BRIDGE=br0

 

서버 재기동(reboot) 후 IP 정보 확인

$ reboot


$ ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.255.255.241  netmask 255.255.255.0  broadcast 10.255.255.255
        inet6 fe80::a00:27ff:fe76:a72e  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:76:a7:2e  txqueuelen 1000  (Ethernet)
        RX packets 75  bytes 7063 (6.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 75  bytes 8832 (8.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 08:00:27:76:a7:2e  txqueuelen 1000  (Ethernet)
        RX packets 91  bytes 9523 (9.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 75  bytes 8976 (8.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.08002776a72e       no              enp0s3
virbr0          8000.525400ad503d       yes             virbr0-nic

 

PC에 Xming 설치

** Xming 설치 후 트레이에 아이콘 확인

 

putty와 Xming 연동

 

세션 생성

- Host Name

- Port

Enable X11 forwarding 체크

- Connection -> SSH -> X11 -> X11 forwarding => Enable X11 forwarding 

세션 저장

- Session -> Save

저장한 세션으로 서버 접속

- 저장한 세션 -> Load

터미널에서 virt-manager 명령어 입력

$ virt-manager

 

 

댓글
댓글쓰기 폼