Ubuntu環境的docker實踐——SDN進階操做

[TOC] #1.複製主機文件到容器 爲了方便後續安裝,將本地已有的安裝包直接複製到容器內。java

docker cp <主機目錄> <容器id>:<容器內目錄>

例如將本地/home/ubuntu/Downloads/內的文件複製到容器99e69f9c2311的/home/apps中linux

$ docker cp /home/ubuntu/Downloads/ 99e69f9c2311:/home/apps

#2.容器內Java安裝 將jdk安裝文件jdk-8u231-linux-x64.tar.gz拷貝到容器的/usr/local/java目錄下(也可選擇其餘目錄),解壓 配置環境變量git

$ nano ~/.bashrc

在末尾追加如下內容,crtl o保存,ctrl x退出github

export JAVA_HOME=/usr/local/java/**jdk1.8.0_231**
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

使配置生效web

$ source ~/.bashrc

#3.容器內安裝OpenDayLight 0.4.4-Beryllium-SR4 和 0.6.4-Carbondocker

  • <span style="color:red">安裝時遇到的坑</span>:jdk 11不支持Beryllium(Carbon沒試過),解壓後karaf沒法啓動,要用jdk 8 以後安裝和正常環境下一致。
  • 爲了方便查看ip,須要使用ifconfig命令,若是在/sbin/下找不到,就要安裝
$ apt-get install net-tools
  • 打包更新鏡像
$ docker commit -m "install odl Be and C" -a "wdf000" 99e69f9c2311 wdf000/opendaylight:20200108
  • 在新的鏡像上運行新的容器,取名爲odl,還要將6633/6653兩個控制器和交換機的通信端口,以及8181控制器的web端口映射到外層系統主機,便於外層系統直接訪問
$ docker run -itd -p 8181:8181 -p 6653:6653 -p 6633:6633 --name odl wdf000/opendaylight:20200108

運行容器ODL,並啓動控制器,在外層系統主機直接訪問。ubuntu

#4.安裝SDN 仿真工具Mininet ##直接裝在容器內bash

  • <span style="color:red">安裝時遇到的坑</span>:執行安裝腳本~/mininet/util/install.sh時報錯./install.sh: line 46: sudo: command not found 方法以下:
$ apt-get update
$ apt-get install sudo
$ #修改DNS,添加阿里的DNS(保留原有的DNS)
$ sudo nano /etc/resolv.conf

nameserver 223.5.5.5  
nameserver 223.6.6.6

附上阿里Ubuntu鏡像的源網絡

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
  • <span style="color:red">安裝時遇到的坑</span>:下載openflow時網速很慢,下載進度卡住不動了 方法以下: 修改install.sh腳本,將git clone git://github.com/mininet/openflow 修改成 git clone https://github.com/mininet/openflow.gitapp

  • <span style="color:red">安裝時遇到的坑</span>:下載optest時報錯:fatal: read error: Connection reset by peer 方法以下: 修改install.sh安裝腳本,將git clone git://github.com/floodlight/oftest 修改成 git clone https://github.com/floodlight/oftest.git

  • 終於裝好了

  • <span style="color:red">運行時遇到的坑</span>:Error setting resource limits. Mininet's performance may be affected. <span style="color:blue">暫時沒有解決。</span>

##安裝在ubuntu上

$ git clone https://github.com/mininet/mininet.git
$ sudo ./mininet/util/install.sh -a

安裝過程若是遇到網絡問題,按照前面說的方法,修改安裝腳本里面git clone的地址便可解決。 運行正常。(容器內安裝極可能由於資源不足的緣由,纔會出現運行錯誤,容器內使用的ubuntu是從hub docker上pull下來的,只有百兆,和實際的ubuntu功能會差不少。)

#5.Mininet鏈接運行在容器內的OpenDaylight

$ 獲取容器ip地址
$ docker inspect --format '{{.NetworkSettings.IPAddress }}' <容器id>

##Carbon

$ sudo mn --controller=remote,ip=172.17.0.2,port=6633 --switch=ovsk,protocols=OpenFlow13

##Beryllium 剛開始控制器沒連上,嘗試將6633端口改成6653,成功。

$ sudo mn --controller=remote,ip=172.17.0.2,port=6653 --switch=ovsk,protocols=OpenFlow13

相關文章
相關標籤/搜索