메뉴 닫기

kvm + openvswitch 연동

최근 네트웍 가상화 SDN, NFV가 가장 핫한 이슈가 되고 있습니다.
오픈 소스중에 openvswitch가 그중 가장 대중적으로 알려진 네트워크 가상화 
프로그램입니다.

openvswitch와 kvm을 연동하여 설치후 vm의 리소스 및 네트웍까지 확인 해보겠습니다.

서버 OS는 우분투 14.04 LTS 이며 1 NIC으로 진행 하겠습니다.

– 서버 설치 후 업데이트 진행


root@ubuntu:~# apt-get update && apt-get dist-upgrade
무시http://kr.archive.ubuntu.com trusty InRelease
받기:1 http://kr.archive.ubuntu.com trusty-updates InRelease [64.4 kB]
받기:2 http://kr.archive.ubuntu.com trusty-backports InRelease [64.5 kB] 
받기:3 http://kr.archive.ubuntu.com trusty Release.gpg [933 B] 
받기:4 http://kr.archive.ubuntu.com trusty Release [58.5 kB] 
.
.
.
ubuntu-release-upgrader-core udev unattended-upgrades update-manager-core
update-notifier-common util-linux uuid-runtime wget wpasupplicant
179개 업그레이드, 4개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
134 M바이트 아카이브를 받아야 합니다.
이 작업 후 291 M바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] y

– 패키지 설치


root@ubuntu:~# apt-get install openvswitch-switch qemu-kvm libvirt-bin
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다 
상태 정보를 읽는 중입니다... 완료
다음 패키지를 더 설치할 것입니다:
acl augeas-lenses bridge-utils cgroup-lite cpu-checker dnsmasq-base ebtables
iproute ipxe-qemu libaio1 libasound2 libasound2-data libasyncns0 libaugeas0
libavahi-client3 libavahi-common-data libavahi-common3 libbluetooth3
libboost-system1.54.0 libboost-thread1.54.0 libbrlapi0.6 libcaca0 libfdt1
libflac8 libjpeg-turbo8 libjpeg8 libmnl0 libnetcf1 libnetfilter-conntrack3
libnl-route-3-200 libnspr4 libnss3 libnss3-nssdb libogg0 libpciaccess0
libpixman-1-0 libpulse0 librados2 librbd1 libsdl1.2debian libseccomp2
libsndfile1 libspice-server1 libusbredirparser1 libvirt0 libvorbis0a
libvorbisenc2 libx86-1 libxen-4.4 libxenstore3.0 libxml2-utils libxslt1.1
libyajl2 msr-tools openvswitch-common pm-utils qemu-keymaps
qemu-system-common qemu-system-x86 qemu-utils seabios sharutils vbetool
제안하는 패키지:
augeas-doc libasound2-plugins alsa-utils augeas-tools pulseaudio radvd lvm2
openvswitch-datapath-module cpufrequtils radeontool samba vde2 sgabios
kvm-ipxe-precise debootstrap bsd-mailx mailx
다음 새 패키지를 설치할 것입니다:
acl augeas-lenses bridge-utils cgroup-lite cpu-checker dnsmasq-base ebtables
iproute ipxe-qemu libaio1 libasound2 libasound2-data libasyncns0 libaugeas0
libavahi-client3 libavahi-common-data libavahi-common3 libbluetooth3
libboost-system1.54.0 libboost-thread1.54.0 libbrlapi0.6 libcaca0 libfdt1
libflac8 libjpeg-turbo8 libjpeg8 libmnl0 libnetcf1 libnetfilter-conntrack3
libnl-route-3-200 libnspr4 libnss3 libnss3-nssdb libogg0 libpciaccess0
libpixman-1-0 libpulse0 librados2 librbd1 libsdl1.2debian libseccomp2
libsndfile1 libspice-server1 libusbredirparser1 libvirt-bin libvirt0
libvorbis0a libvorbisenc2 libx86-1 libxen-4.4 libxenstore3.0 libxml2-utils
libxslt1.1 libyajl2 msr-tools openvswitch-common openvswitch-switch pm-utils
qemu-keymaps qemu-kvm qemu-system-common qemu-system-x86 qemu-utils seabios
sharutils vbetool
0개 업그레이드, 66개 새로 설치, 0개 제거 및 0개 업그레이드 안 함.
14.4 M바이트 아카이브를 받아야 합니다.
이 작업 후 71.6 M바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n] y

– kvm, openvswitch 버전 확인


root@ubuntu:~# libvirtd --version
libvirtd (libvirt) 1.2.2

root@ubuntu:~# kvm -version
QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.21), Copyright (c) 2003-2008 Fabrice Bellard

root@ubuntu:~# ovs-vsctl --version
ovs-vsctl (Open vSwitch) 2.0.2
Compiled Dec 9 2015 14:08:08

– network 파일 수정
기존


auto p119p1
iface p119p1 inet static
address 211.xxxx.xxx.131
netmask 255.255.255.248
gateway 211.xxx.xxx.129
dns-nameservers 115.68.62.210

수정


auto p119p1
iface p119p1 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down

auto br0
iface br0 inet static
address 211.xxxx.xxx.131
netmask 255.255.255.248
gateway 211.xxx.xxx.129
dns-nameservers 115.68.62.210

– vswitch 생성


root@ubuntu:~# ovs-vsctl add-br br0
root@ubuntu:~# ovs-vsctl show
0ce27604-281b-4820-a918-da643c646e90
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
ovs_version: "2.0.2"

– vswitch 포트 추가


root@ubuntu:~# ovs-vsctl add-port br0 p119p1 && reboot 
root@ubuntu:~# 
Broadcast message from smileserv@ubuntu
(/dev/pts/1) at 13:52 ...

The system is going down for reboot NOW!

root@ubuntu:~# ovs-vsctl show
0ce27604-281b-4820-a918-da643c646e90
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
Port "p119p1"
Interface "p119p1"
ovs_version: "2.0.2"

– test vm 다운로드


root@ubuntu:~# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
--2016-01-29 14:05:34-- http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 69.163.241.114
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|69.163.241.114|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13287936 (13M) [text/plain]
Saving to: ‘cirros-0.3.4-x86_64-disk.img’

100%[================================================================================================================================================>] 13,287,936 4.24MB/s in 3.0s

2016-01-29 14:05:37 (4.24 MB/s) - ‘cirros-0.3.4-x86_64-disk.img’ saved [13287936/13287936]

root@ubuntu:~# qemu-img info cirros-0.3.4-x86_64-disk.img 
image: cirros-0.3.4-x86_64-disk.img
file format: qcow2
virtual size: 39M (41126400 bytes)
disk size: 13M
cluster_size: 65536
Format specific information:
compat: 0.10

– vm 구동


root@ubuntu:~# cat /etc/qemu-jyh
#! /bin/sh
ip link set $1 up
ovs-vsctl add-port br0 $1
root@ubuntu:~# chmod 700 /etc/qemu-jyh

root@ubuntu:~# qemu-system-x86_64 -net nic,vlan=0,macaddr=00:25:22:F9:C0:BD,model=e1000 -net tap,vlan=0,ifname=jyh,script=/etc/qemu-jyh -daemonize -smp 3 -m 3072 -drive file=/root/cirros-0.3.4-x86_64-disk.img,if=virtio,index=0,media=disk -boot c -vnc :1

root@ubuntu:~# ovs-vsctl show
0ce27604-281b-4820-a918-da643c646e90
Bridge "br0"
Port "br0"
Interface "br0"
type: internal
Port "p119p1"
Interface "p119p1"
Port jyh
Interface jyh
ovs_version: "2.0.2"

root@ubuntu:~# ps -ef |grep qemu
root 1750 1 22 14:15 ? 00:00:18 qemu-system-x86_64 -net nic,vlan=0,macaddr=00:25:22:F9:C0:BD,model=e1000 -net tap,vlan=0,ifname=jyh,script=/etc/qemu-jyh -daemonize -smp 3 -m 3072 -drive file=/root/cirros-0.3.4-x86_64-disk.img,if=virtio,index=0,media=disk -boot c -vnc :1

– vm 리소스 및 네트웍 확인


$ cat /proc/cpuinfo | grep ^processor
processor : 0
processor : 1
processor : 2


$ free -m
total used free shared buffers
Mem: 3011 61 2950 0 0
-/+ buffers: 60 2950
Swap: 0 0 0

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=53 time=32.394 ms

무단 복사, 재배포 금지

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x