Welcome 微信登录

首页 / 操作系统 / Linux / CentOS 6.5下安装Open vSwitch

准备# yum install openssl-devel RedHat-rpm-config kernel-devel -y#yum install kvm libvirt python-virtinst qemu-kvm virt-viewer编译# wget http://openvswitch.org/releases/openvswitch-1.9.3.tar.gz#tar -zxf openvswitch-1.9.3.tar.gz# cd openvswitch-1.9.3# cp ../openvswitch-1.9.3.tar.gz ~/rpmbuild/SOURCES/# cp rhel/openvswitch-kmod.files ~/rpmbuild/SOURCES/# cp rhel/openvswitch.spec ~/rpmbuild/SPECS/# rpmbuild  -ba ~/rpmbuild/SPECS/openvswitch.spec# cp rhel/openvswitch-kmod-rhel6.spec ~/rpmbuild/SPECS/# ls ~/rpmbuild/RPMS/x86_64/ |grep openkmod-openvswitch-1.9.3-1.el6.x86_64.rpmopenvswitch-1.9.3-1.x86_64.rpmopenvswitch-debuginfo-1.9.3-1.x86_64.rpm# rpm -ihv openvswitch-1.9.3-1.x86_64.rpm  kmod-openvswitch-1.9.3-1.el6.x86_64.rpmPreparing...                ########################################### [100%]1:kmod-openvswitch      ########################################### [ 50%]WARNING: /lib/modules/2.6.32-431.el6.x86_64/weak-updates/openvswitch/brcompat.ko needs unknown symbol ovs_dp_ioctl_hook2:openvswitch            ########################################### [100%]使用openvswitch# virsh net-destroy default# virsh net-autostart --disable default# service openvswitch start/etc/openvswitch/conf.db does not exist ... (warning).Creating empty database /etc/openvswitch/conf.db [  OK  ]Starting ovsdb-server [  OK  ]Configuring Open vSwitch system IDs [  OK  ]Inserting openvswitch module [  OK  ]Starting ovs-vswitchd [  OK  ]Enabling gre with iptables [  OK  ]# ovs-vsctl add-br br0/etc/sysconfig/network-scripts/ifcfg-br0DEVICE=br0ONBOOT=yesDEVICETYPE=ovsTYPE=OVSBridgeBOOTPROTO=staticIPADDR=172.16.213.131NETMASK=255.255.255.0GATEWAY=172.16.213.2HOTPLUG=no/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yesDEVICETYPE=ovsTYPE=OVSPortOVS_BRIDGE=br0BOOTPROTO=noneHOTPLUG=no# service network restart# ovs-vsctl show1bc18f94-0b5c-44c2-afd5-ac7d370499f1Bridge "br0"Port "eth0"Interface "eth0"Port "br0"Interface "br0"type: internalovs_version: "1.9.3"在KVM中使用OVS# yum install bridge-utils tunctl[root@yinye ~]# virt-install --name=CentOS65 --ram 512 --vcpus=1  -f /root/kvm/centos65.qcow2 --cdrom /root/CentOS-6.5-x86_64-minimal.iso --graphics vnc,listen=0.0.0.0,port=5920,  --network bridge=br0WARNING  KVM acceleration not available, using "qemu"开始安装......ERROR    Unable to add bridge br0 port vnet0: Operation not supportedDomain installation does not appear to have been successful.If it was, you can restart your domain by running:virsh --connect qemu:///system start centos65otherwise, please restart your installation.如果不在命令行指定bridge为openvswitch类型 ,libvirt会尝试linux默认的bridge,而virt-install又不支持openvswitch。详细参考https://www.redhat.com/archives/libvirt-users/2013-May/msg00043.html# virt-install --connect qemu:///system --name=centos65 --ram 512 --vcpus=1  -f /home/kvm/centos65.qcow2 --cdrom /home/kvm/CentOS-6.5-x86_64-minimal.iso --graphicsvnc,listen=0.0.0.0,port=5920,  --nonetworksvirsh # edit centos65增加<interface type="bridge"><source bridge="br0"/><virtualport type="openvswitch" /><model type="virtio"/></interface>virsh # start centos65配置guest os的网卡# cat /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yesTYPE=EthernetHWADDR=52:54:00:D8:D7:FBBOOTPROTO=dhcp#ifup eth0更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14本文永久更新链接地址