博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OVS搭建虚拟机全过程(四十五)
阅读量:3701 次
发布时间:2019-05-21

本文共 2602 字,大约阅读时间需要 8 分钟。

系统:ubuntu14.04.1

内核:4.4.0

Install OVS

1. Download OVS

cd /usr/srcwget http://openvswitch.org/releases/openvswitch-2.6.6.tar.gztar -zxvf openvswitch-2.6.6.tar.gzexport OVS_DIR=/usr/src/openvswitch-2.6.6

2. Install OVS dependencies

sudo apt-get updatesudo apt-get install build-essential libssl-dev linux-headers-$(uname -r) graphviz autoconf automake bzip2 debhelper dh-autoreconf libssl-dev libtool openssl procps python-all python-qt4 python-twisted-conch python-zopeinterface python-six dkms module-assistant ipsec-tools racoon  libc6-dev  module-init-tools  netbase  python-argparse  uuid-runtime automake openssl libcap-ng-dev python-pip gccsudo pip install six

参考链接:

3. Configure and Install OVS

cd $OVS_DIR./boot.sh./configuremake install

注意:建议将所有环境变量保存到/etc/profile中,这样重启之后依旧可以使用,如

vi /etc/profile
export OVS_DIR=/usr/src/openvswitch-2.6.6export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
source /etc/profile

4. Load openvswitch

/sbin/modprobe openvswitch

5. Setup OVS

创建DB

mkdir -p /usr/local/etc/openvswitchmkdir -p /usr/local/var/run/openvswitchrm /usr/local/etc/openvswitch/conf.dbovsdb-tool create /usr/local/etc/openvswitch/conf.db  \       /usr/local/share/openvswitch/vswitch.ovsschema

启动ovsdb-server

ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \         --remote=db:Open_vSwitch,Open_vSwitch,manager_options \         --pidfile --detach --log-file

初始化DB

ovs-vsctl --no-wait init

启动vswitchd

export DB_SOCK=/usr/local/var/run/openvswitch/db.sockovs-vswitchd unix:$DB_SOCK --pidfile --detach --log-file

创建bridge和并绑定网卡设备

ovs-vsctl add-br br0ovs-vsctl add-port br0 eth0

配置br0地址

当eth0绑定到br0上时,eth0的ip已经失效,注意到br0会生成一个type为internal的port br0,我们可以将eth0的网卡地址绑定到br0上

ifconfig eth0 0.0.0.0 upifconfig br0 10.10.27.165/24 up

再配置一下网关,即可连接外网

ip route add default via 10.10.26.1 dev br0

Setup the Guest

1. Install dependencies

apt-get install uml-utilities

2. Create custom scripts

vi /etc/ovs-ifup
#!/bin/shswitch='br0'/sbin/ifconfig $1 0.0.0.0 upovs-vsctl add-port ${
switch} $1
vi /etc/ovs-ifdown
#!/bin/shswitch='br0'/sbin/ifconfig $1 0.0.0.0 downovs-vsctl del-port ${
switch} $1

注意:将/etc/ovs-ifup和/etc/ovs-ifdown文件设置为可执行

chmod +x /etc/ovs-ifupchmod +x /etc/ovs-ifdown

3. Install Guest

qemu-system-x86_64 -m 512 -cpu host -drive file=/home/bob/images/ubuntu1.qcow2 -enable-kvm -net nic,macaddr=00:00:00:00:00:01 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -vnc :0qemu-system-x86_64 -m 512 -cpu host -drive file=/home/bob/images/ubuntu2.qcow2 -enable-kvm -net nic,macaddr=00:00:00:00:00:02 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -vnc :1

转载地址:http://cvxcn.baihongyu.com/

你可能感兴趣的文章
@mapper
查看>>
mapper
查看>>
Controller层
查看>>
导航栏错误
查看>>
Controller ----Service ----Mapper
查看>>
Cache 缓存处理
查看>>
关于Redis闪退
查看>>
Redis cuowu
查看>>
Spring boot01
查看>>
Spring boot配置文件
查看>>
springboot-10-11
查看>>
spring-10.15 通过Aware接口使用spring底层组件
查看>>
spring-quartz-10.15框架独立使用与spring整合
查看>>
springMVC -10.21-01
查看>>
数据结构---单链表
查看>>
ACM日记(补)
查看>>
好题集锦
查看>>
ACM日记 再补
查看>>
ACM日记
查看>>
Acm日记
查看>>