标签:openvswitch centos6.x 安装及使用
摘要
openvswitch 虚拟交换机 centos6.x 编译安装及简单vlan配置
安装编译环境
#yum install gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool
编译rpm建议使用普通用户
下载创建编译目录脚本
$wget ftp://ftp.owlriver.com/pub/local/COLUG//RPM-build-tree.txt
执行脚本
$sh RPM-build-tree.txt
将会在当前用户家目录创建如下目录
rpmbuild ├── BUILD├── BUILDROOT├── RPMS ├── SOURCES ├── SPECS └── SRPMS
##切换至家目录 $cd ~ ##下载openvswitch源码包 $wget http://openvswitch.org/releases/openvswitch-2.3.1.tar.gz $cp openvswitch-2.3.1.tar.gz rpmbuild/SOURCES/ $tar xvf openvswitch-2.3.1.tar.gz $cd openvswitch-2.3.1 ##编译内核 $cp rhel/openvswitch-kmod.files ~/rpmbuild/SOURCES/ $rpmbuild -bb rhel/openvswitch-kmod-rhel6.spec ##编译openvswitch rpm $rpmbuild -bb rhel/openvswitch.spec
编译完成后rpm包位于
ll ~/rpmbuild/RPMS/x86_64/ total 11440 -rw-rw-r--. 1 firxiao firxiao 1223288 Dec 17 05:50 kmod-openvswitch-2.3.1-1.el6.x86_64.rpm -rw-rw-r--. 1 firxiao firxiao 2640440 Dec 17 06:01 openvswitch-2.3.1-1.x86_64.rpm -rw-rw-r--. 1 firxiao firxiao 7846548 Dec 17 06:01 openvswitch-debuginfo-2.3.1-1.x86_64.rpm
将openvswitch-2.3.1-1.x86_64.rpm kmod-openvswitch-2.3.1-1.el6.x86_64.rpm 上传至vm1、vm2
使用yum安装
#yum install openvswitch-2.3.1-1.x86_64.rpm kmod-openvswitch-2.3.1-1.el6.x86_64.rpm
启动服务
#/etc/init.d/openvswitch start
vm1 vm2 vm1 and vm2 创建桥接网卡ovsbridge0 ---- ---- 基于ovsbridge0创建vlan100网卡。 eth0 ech0 -------------- ------------- ovsbridge0 ovsbridge0 172.16.0.20/24 172.16.0.21/24 -------------- -------------- vlan100 vlan100 192.168.100.2/24 192.168.100.3/24 ---------------- ----------------
将配置文件放于/etc/sysconfig/network-scripts
[root@vm1 network-scripts]# cat ifcfg-eth0 DEVICE=eth0 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSPort OVS_BRIDGE=ovsbridge0 BOOTPROTO=none HOTPLUG=no [root@vm1 network-scripts]# cat ifcfg-ovsbridge0 DEVICE=ovsbridge0 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSBridge BOOTPROTO=static IPADDR=172.16.0.20 NETMASK=255.255.255.0 HOTPLUG=no [root@vm1 network-scripts]# cat ifcfg-vlan100 DEVICE=vlan100 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSIntPort BOOTPROTO=static IPADDR=192.168.100.2 NETMASK=255.255.255.0 OVS_BRIDGE=ovsbridge0 OVS_OPTIONS="tag=100" OVS_EXTRA="set Interface $DEVICE external-ids:iface-id=$(hostname -s)-$DEVICE-vif" HOTPLUG=no
[root@vm1 ~]# ovs-vsctl show fedbda2f-2516-4aff-b89f-ca221873eb9c Bridge "ovsbridge0" Port "vlan100" tag: 100 Interface "vlan100" type: internal Port "eth0" Interface "eth0" Port "ovsbridge0" Interface "ovsbridge0" type: internal ovs_version: "2.3.1"
[root@vm2 network-scripts]# cat ifcfg-eth0 DEVICE=eth0 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSPort OVS_BRIDGE=ovsbridge0 BOOTPROTO=none HOTPLUG=no [root@vm2 network-scripts]# cat ifcfg-ovsbridge0 DEVICE=ovsbridge0 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSBridge BOOTPROTO=static IPADDR=172.16.0.21 NETMASK=255.255.255.0 HOTPLUG=no [root@vm2 network-scripts]# cat ifcfg-vlan100 DEVICE=vlan100 ONBOOT=yes DEVICETYPE=ovs TYPE=OVSIntPort BOOTPROTO=static IPADDR=192.168.100.3 NETMASK=255.255.255.0 OVS_BRIDGE=ovsbridge0 OVS_OPTIONS="tag=100" OVS_EXTRA="set Interface $DEVICE external-ids:iface-id=$(hostname -s)-$DEVICE-vif" HOTPLUG=no
[root@vm2 ~]# ovs-vsctl show 646f5f0f-6a6b-4b01-9c3c-f7684aa64ecc Bridge "ovsbridge0" Port "eth0" Interface "eth0" Port "ovsbridge0" Interface "ovsbridge0" type: internal Port "vlan100" tag: 100 Interface "vlan100" type: internal ovs_version: "2.3.1"
#service network restart
在vm1 上 vm2 上使用 172.16.0.0/24可以互相通信
使用vlan100 192.168.100.0/24也可进行通信 两个网络互相隔离
编译rpm参考: openvswitch-2.3.1/INSTALL.RHEL
网络配置参考:http://git.openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=rhel/README.RHEL;hb=HEAD
本文出自 “尼古风锁丝愁过” 博客,请务必保留此出处http://smoke520.blog.51cto.com/9256117/1793069
标签:openvswitch centos6.x 安装及使用
原文地址:http://smoke520.blog.51cto.com/9256117/1793069