重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
小編給大家分享一下DDBMS中如何冗余docker網絡,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業的熱愛。我們立志把好的技術通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領域值得信任、有價值的長期合作伙伴,公司提供的服務項目有:國際域名空間、網站空間、營銷軟件、網站建設、望花網站維護、網站推廣。
環境準備:
vmware中配置四臺ubuntu server 14.04(你可以只安裝一個系統,使用克隆功能克隆出另外三臺ubuntu),配置好SSH
每臺機器配置兩個網卡,像openstack一樣,分Internal和External IP。這里我讓eth0(NAT)作為 External,eth2(host-only)作為Internal。
拓撲圖如下:
安裝OVS:
具體安裝教程參考這里:http://www.sdnlab.com/3166.html
附上我的OVS啟動腳本:
ovs_launch #!/bin/bash #launch the ovs ovsdb-server -v --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --pidfile --detach #init the database ovs-vsctl --no-wait init #launch the main process ovs-vswitchd --pidfile --detach #print the version infomation ovs-vsctl --version echo echo 'OpenVswitch have been launched successfully!'
保存并放置該腳本
chmod +x ovs_launch mv ovs_launch /usr/local/bin
安裝pipework工具:
git clone https://github.com/jpetazzo/pipework cp ~/pipework/pipework /usr/local/bin/
安裝docker最新的版本:https://docs.docker.com/installation/ubuntulinux/
pull一個鏡像:
docker pull ubuntu
創建掛載容器用的br0和br1網橋:
brctl addbr br0 ip link set dev br0 up ip addr add 192.168.2.1/24 dev br0 brctl addbr br1 ip link set dev br1 up ip addr add 192.168.3.1/24 dev br1
在每臺host上配置OVS(每次開機先執行ovs_launch):
ovs-vsctl add-br ovs0 ovs-vsctl set bridge ovs0 stp_enable=true ovs-vsctl add-port ovs0 br0 ovs-vsctl add-port ovs0 br1
創建host1tohost2的vxlan或gre隧道(這里我用的是gre):
ovs-vsctl add-port ovs0 gre0 -- set interface gre0 type=gre options:remote_ip=10.20.10.71
創建host2tohost1的gre隧道:
ovs-vsctl add-port ovs0 gre0 -- set interface gre0 type=gre options:remote_ip=10.20.10.70
創建host2tohost3的隧道:
ovs-vsctl add-port ovs0 gre1 -- set interface gre1 type=gre options:remote_ip=10.20.10.72
創建host3tohost2的隧道:
ovs-vsctl add-port ovs0 gre1 -- set interface gre1 type=gre options:remote_ip=10.20.10.71
創建host3tohost4的隧道:
ovs-vsctl add-port ovs0 gre2 -- set interface gre2 type=gre options:remote_ip=10.20.10.73
創建host4tohost3的隧道:
ovs-vsctl add-port ovs0 gre2 -- set interface gre2 type=gre options:remote_ip=10.20.10.72
創建host4tohost1的隧道:
ovs-vsctl add-port ovs0 gre3 -- set interface gre3 type=gre options:remote_ip=10.20.10.70
創建host1tohost4的隧道:
ovs-vsctl add-port ovs0 gre3 -- set interface gre3 type=gre options:remote_ip=10.20.10.73
(注意,兩臺主機間的互通隧道名相同,且每個OVS上不能出現重名的隧道)
啟動容器并測試:
host1:
docker run -itd --name=test1 ubuntu pipework br0 test1 192.168.2.11/24
host2:
docker run -itd --name=test1 ubuntu pipework br0 test1 192.168.2.12/24
host3:
docker run -itd --name=test1 ubuntu pipework br1 test1 192.168.3.11/24
host4:
docker run -itd --name=test1 ubuntu pipework br1 test1 192.168.3.12/24
進入容器進行測試,你會發現,無論哪個容器,只要掛在同一個br網橋(同一網段),它們都是互通的。當然,如果你用192.168.2.11 ping 192.168.3.11那是絕對不行的(除非你不把br0和br1掛在ovs0上,此時route會進行路由,這種情況下可以互通)。
此時,你就建立了一個冗余的docker容器網絡。
以上是“DDBMS中如何冗余docker網絡”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創新互聯行業資訊頻道!