weave官网 https://www.weave.works
1. 下载安装
sudo curl -L git.io/weave -o /usr/local/bin/weave
sudo chmod a+x /usr/local/bin/weave
2. 部署weave网络
(1) 在第一台机器上运行,如果使用默认的 10.0.*.* 网段则如下
weave launch
本次测试使用自定义的网段,所以启动指令有所不同:
weave launch --ipalloc-range 168.108.0.0/
启动成功后,会有3个weave的容器运行中
# docker ps -a
c9ed14e97dfd weaveworks/weave:2.0. "/home/weave/weave..." days ago Up days weave
7db070b5f54e weaveworks/weaveexec:2.0. "/bin/false" days ago Created weavevolumes-2.0.
b6d603c8c7a8 weaveworks/weavedb "data-only" days ago Created weavedb
可看到增加了虚拟网卡 weave
# ifconfig
datapath: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
ether a6::9d:b6:5f: txqueuelen (Ethernet)
RX packets bytes (84.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions docker0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 192.168.0.1 netmask 255.255.240.0 broadcast 0.0.0.0
ether :::9e::4b txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions docker_gwbridge: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.16.1 netmask 255.255.240.0 broadcast 0.0.0.0
ether ::b9::2f:b8 txqueuelen (Ethernet)
RX packets bytes (28.1 MiB)
RX errors dropped overruns frame
TX packets bytes (28.1 MiB)
TX errors dropped overruns carrier collisions eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.28.148.61 netmask 255.255.252.0 broadcast 10.28.151.255
ether ::3e:0e::7a txqueuelen (Ethernet)
RX packets bytes (11.5 GiB)
RX errors dropped overruns frame
TX packets bytes (7.9 GiB)
TX errors dropped overruns carrier collisions eth1: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 101.37.162.152 netmask 255.255.252.0 broadcast 101.37.163.255
ether ::3e:0e::ce txqueuelen (Ethernet)
RX packets bytes (513.3 MiB)
RX errors dropped overruns frame
TX packets bytes (4.3 GiB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen (Local Loopback)
RX packets bytes (28.1 MiB)
RX errors dropped overruns frame
TX packets bytes (28.1 MiB)
TX errors dropped overruns carrier collisions veth7720327: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
ether 7e::f5::6d:9e txqueuelen (Ethernet)
RX packets bytes (372.0 B)
RX errors dropped overruns frame
TX packets bytes (798.0 B)
TX errors dropped overruns carrier collisions weave: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
ether c2:a6::::0a txqueuelen (Ethernet)
RX packets bytes (84.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions
(2) 其他的节点加入加入上面已经创建的weave网络
weave launch 10.28.148.61 --ipalloc-range 168.108.0.0/
(3) 创建网络成功的话,在每个节点上都可以用docker命令查看到weave网络
# docker network ls
NETWORK ID NAME DRIVER SCOPE
7c19813ffbff bridge bridge local
a7a2188380ba docker_gwbridge bridge local
7f97ac1cfe6e host host local
z08xcdlswkbk ingress overlay swarm
dfa68b3918b3 none null local
42f695c8c061 weave weavemesh local
3. docker启动测试
(1) 启动相当简单,仅需正常的docker命令中指定network为weave就行了
docker run -ti --network weave mytest
(2) 在2个节点上启动容器
在容器内部ifconfig可以看到容器使用的是weave的子网段,2个节点分别是168.108.0.1和168.108.192.0
[root@f451f6736785 /]# ifconfig
ethwe0 Link encap:Ethernet HWaddr :6E:BF:E4::A7
inet addr:168.108.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (42.0 b) TX bytes: (42.0 b) eth0 Link encap:Ethernet HWaddr ::C0:A8::
inet addr:192.168.16.6 Bcast:0.0.0.0 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (0.0 b) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (0.0 b)
[root@7c202270ff9f /]# ifconfig
ethwe0 Link encap:Ethernet HWaddr F6:8D:A2:CB:EF:F5
inet addr:168.108.192.0 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (42.0 b) eth0 Link encap:Ethernet HWaddr ::C0:A8::
inet addr:192.168.16.3 Bcast:0.0.0.0 Mask:255.255.240.0
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (0.0 b) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (0.0 b)
在容器里可以互相ping通
[root@f451f6736785 /]# ping 168.108.192.0
PING 168.108.192.0 (168.108.192.0) () bytes of data.
bytes from 168.108.192.0: icmp_seq= ttl= time=0.935 ms
bytes from 168.108.192.0: icmp_seq= ttl= time=0.334 ms
bytes from 168.108.192.0: icmp_seq= ttl= time=0.257 ms
bytes from 168.108.192.0: icmp_seq= ttl= time=0.386 ms
^C
--- 168.108.192.0 ping statistics ---
packets transmitted, received, % packet loss, time 3845ms
rtt min/avg/max/mdev = 0.257/0.478/0.935/0.267 ms
[root@7c202270ff9f /]# ping 168.108.0.1
PING 168.108.0.1 (168.108.0.1) () bytes of data.
bytes from 168.108.0.1: icmp_seq= ttl= time=0.428 ms
bytes from 168.108.0.1: icmp_seq= ttl= time=0.274 ms
bytes from 168.108.0.1: icmp_seq= ttl= time=0.344 ms
bytes from 168.108.0.1: icmp_seq= ttl= time=0.341 ms
^C
--- 168.108.0.1 ping statistics ---
packets transmitted, received, % packet loss, time 8592ms
rtt min/avg/max/mdev = 0.235/0.301/0.428/0.056 ms
(3) 网速测试:
本次测试的环境是阿里云上的ECS,内网带宽为 1Gbits。
先安装iperf3(网速测试工具)
curl "http://downloads.es.net/pub/iperf/iperf-3.0.6.tar.gz" -o iperf-3.0..tar.gz
tar xzvf iperf-3.0..tar.gz
cd iperf-3.0.
./configure
make
make install
在节点2上启动iperf服务
# iperf3 -s
-----------------------------------------------------------
Server listening on
-----------------------------------------------------------
在节点1上启动网速测试
# iperf3 -c 168.108.192.0
Connecting to host 168.108.192.0, port
[ ] local 168.108.0.1 port connected to 168.108.192.0 port
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ ] 0.00-1.00 sec MBytes 1.42 Gbits/sec KBytes
[ ] 1.00-2.00 sec 95.2 MBytes Mbits/sec KBytes
[ ] 2.00-3.00 sec 95.0 MBytes Mbits/sec KBytes
[ ] 3.00-4.00 sec 96.2 MBytes Mbits/sec KBytes
[ ] 4.00-5.00 sec 93.8 MBytes Mbits/sec KBytes
[ ] 5.00-6.00 sec 95.0 MBytes Mbits/sec KBytes
[ ] 6.00-7.00 sec 95.0 MBytes Mbits/sec KBytes
[ ] 7.00-8.00 sec 95.0 MBytes Mbits/sec KBytes
[ ] 8.00-9.00 sec 93.8 MBytes Mbits/sec KBytes
[ ] 9.00-10.00 sec 95.0 MBytes Mbits/sec KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ ] 0.00-10.00 sec MBytes Mbits/sec sender
[ ] 0.00-10.00 sec MBytes Mbits/sec receiver iperf Done.
测试下来平均网速:发送速度 859 Mbits/sec ,收取速度 856 Mbits/sec。网速还是让人比较满意的。