(菜汪学docker) 用vmware 完成 docker+ovs+vxlan 实现容器跨主机访问

来源:互联网 发布:wnba赛果数据 编辑:程序博客网 时间:2024/06/06 06:34

本汪刚开始学习ovs,觉得这不是一天两天就能学会的东西,所以就不谈感想和总结了,分享一下我的学习链接吧,自己耐心感悟吧。

学习链接
ovshttp://blog.csdn.net/tantexian/article/details/46707175ovshttp://www.cnblogs.com/popsuper1982/p/5848879.htmlopenflowhttp://blog.csdn.net/wangpengqi/article/details/17400947ovshttp://vinllen.com/ovs-datapathbi-ji/ovs 实验http://www.sdnlab.com/8236.htmldocker 网络http://www.infoq.com/cn/articles/docker-network-and-pipework-open-source-explanation-practicedockerhttp://www.cnblogs.com/sammyliu/p/5878973.html

开始vmware试验,这里虚拟机我觉的必须双网卡才能完成这个试验,可能由于是vmware虚拟机的原因吧。害羞

先上一张比较low的图

配置虚拟机ABC的网络 A:192.168.0.11 B(两块网卡):192.168.0.16 192.168.0.18(eno33554992)  C(两块网卡):192.168.0.17 192.168.0.19(eno33554992)

虚拟机A要能访问到B C
修改三台机器的系统参数fs.aio-max-nr = 65536net.bridge.bridge-nf-call-iptables = 1net.bridge.bridge-nf-call-iptables = 1net.bridge.bridge-nf-call-ip6tables = 1
网关配置虚拟机BC的网关配置为虚拟机A的IP安装docker这个百度吧 大把大把的文章

安装ovs

modprobe  openvswitch# ovs的核心模块,配合ovs-vswitchd使用insmod datapath/openvswitch.ko创建ovsdb数据库ovsdb-tool create /usr/local/share/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema启动ovs-servernohup ovsdb-server /usr/local/share/openvswitch/conf.db --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=ptcp:6640 --pidfile=ovsdb-server.pid >> /app/ovs/log.txt 2>&1 &
ovs-vsctl --no-wait init启动ovs-switchnohup ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock -v --pidfile >> /app/ovs/switch.log 2>&1 &
进入配置部分

配置虚拟机ABC的网络A:192.168.0.11 B(两块网卡):192.168.0.16 192.168.0.18(eno33554992)  C(两块网卡):192.168.0.17 192.168.0.19(eno33554992)虚拟机A虚拟机A要能访问到B C修改三台机器的系统参数fs.aio-max-nr = 65536
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
网关配置虚拟机BC的网关配置为虚拟机A的IP基本要求docker启动  虚拟机B --bip 192.168.16.0/24;虚拟机A --bip 192.168.17.0/24每个docker上启动两个容器docker run -d -it --name=test16y01 --privileged=true -v /app/docker/waigua/:/app/docker/waigua/ --net=none centos:08.21 /bin/bash
安装ovs虚拟机C上ovs-vsctl add-br sdn-br0
ovs-vsctl set bridge sdn-br0 stp_enable=true
ifconfig sdn-br0 192.168.16.2/24 up
 ovs-vsctl add-port sdn-br0 eno33554992
虚拟机D上ovs-vsctl add-br sdn-br0
ovs-vsctl set bridge sdn-br0 stp_enable=true
ifconfig sdn-br0 192.168.17.2/24 up
 ovs-vsctl add-port sdn-br0 eno33554992
虚拟机C上提前下载pipwork大哭  ./pipework sdn-br0 39f80cbc3c5a 192.168.16.6/24 这种命令形式,把两个容器添加上IP(192.168.16.6 192.168.16.7)虚拟机D上./pipework sdn-br0 39f80cbc3c5a 192.168.16.6/24 这种命令形式,把两个容器添加上IP(192.168.17.6 192.168.17.7)测试网络同一机器上的容器可以互通 ,跨机器就不通了虚拟机C上ovs-vsctl add-port sdn-br0 vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip=192.168.0.17虚拟机D上ovs-vsctl add-port sdn-br0 vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip=192.168.0.16测试网络不出意外,容器之间是通的了
如有错误,或者问题,不要羞涩,请提问我,谢谢。再见
 
阅读全文
0 0
原创粉丝点击