Ubuntu上にKVMとOPEN vSwitchインストール

OSの更新

sudo apt-get update -y && sudo apt-get dist-upgrade && uname -a

KVMのインストール

sudo apt-get install kvm libvirt-bin virtinst

ifconfigでvirbr0ができているか確認

ifconfig

linux bridgeじゃなくてOpen vSwitchを使うのが目的なので削除

sudo virsh net-destroy default
sudo virsh net-autostart --disable default
sudo aptitude purge ebtables

OVS(Open vSwitch)のインストール

sudo apt-get install openvswitch-controller openvswitch-brcompat openvswitch-switch openvswitch-datapath-source

bridge compatibility mode

インストールしたら
OVSを bridge compatibility mode?にするそうで

vim /etc/default/openvswitch-switch

#BRCOMPAT=no

BRCOMPAT=yes

に変更し起動

OVS起動

sudo service openvswitch-switch start

カーネルモジュールの確認

lsmod | grep brcom

でbrcompat_mod と openvswitch_mod

OVSPID確認

service openvswitch-switch status

ovsdb-server
ovs-vswitchd
ovs-brcompatd

OVSコンフィグ確認

sudo ovs-vsctl show

で設定空

を確認

TIPS

virbr0とか消し忘れるとエラーがでるようなので

FATAL: Module brcompat not found.
* Inserting brcompat module
Module has probably not been built for this kernel.
For instructions, read
/usr/share/doc/openvswitch-datapath-source/README.Debian
FATAL: Module brcompat not found.
* Inserting brcompat module

FATAL: Error inserting brcompat (/lib/modules/3.5.0-25-generic/kernel/brcompat.ko): Unknown symbol in module, or unknown parameter (see dmesg)
* Inserting brcompat module
Module has probably not been built for this kernel.
For instructions, read
/usr/share/doc/openvswitch-datapath-source/README.Debian
FATAL: Error inserting brcompat (/lib/modules/3.5.0-25-generic/kernel/brcompat.ko): Unknown symbol in module, or unknown parameter (see dmesg)
* Inserting brcompat module

その時は 以下のようにするらしい

sudo module-assistant auto-install openvswitch-datapath

んだけど これでもだめで

bridge modが読み込まれてるとだめっぽいのでそこの対策をしました

参考:
http://networkstatic.net/openvswitch-configure-from-packages-and-attaching-to-a-floodlight-openflow-controller/

# Fix
# Unload the Linux bridging module “bridge”, will be loaded on reboot w/this method: $ lsmod | grep bridge
#If it is you can remove it temporarily until a reboot: $ rmmod bridge

# Blacklist the ko module to make the removal persistent through reboots: Edit /etc/modprobe.d/blacklist Add: blacklist bridge

# Delete the bridge-utils package:

#Ubuntu
$ apt-get purge bridge-utils

#Redhat
$ yum remove bridge-utils Verify block/removal
$ lsmod | grep bridge

上記のとおり

lsmod|grep bridge

rmmod bridge

vim /etc/modprobe.d/blacklist

  1. blacklist bridge

sudo apt-get purge bridge-utils

そのあと再起動し

lsmod|grep br

brcompat 13513 0
openvswitch 84124 1 brcompat

service openvswitch-switch status

ovsdb-server is running with pid 1116
ovs-vswitchd is running with pid 1130
ovs-brcompatd is running with pid 1133

ってことで大丈夫でした

kernelバージョンアップするとうまく入らない臭い

その時は上にも書いたけど

module-assistant auto-install openvswitch-datapath
とかしてインストールする

その時

sudo apt-get install module-assistant
とか必要かも