目前我这里docker主要使用1.5版本,用途是给研发、运维做测试环境,给游戏与平台业务做生产应用,昨天接到某游戏研发反馈,2个不同宿主机进行数据同步的时候,出现以下错误

orrupted MAC on input.
Disconnecting: Packet corrupt
lost connection

经过谷歌搜索发现问题原因是

"Corrupted MAC on input"
This situation happens when the packet is decrypted, the length field is checked, the MAC is computed over the decrypted data and then checked against the MAC field from the SSH packet (see the picture above). If those two MACs don't match we print the "bad mac" error message.
Possible reasons for "Corrupted MAC on input"
If you see those messages instead of the "Bad packet length" one you can safely assume that the encryption/decryption works fine. If it wasn't then the packet length check could hardly pass a few times in a row - assuming we have seen the message a couple of times at least. That means that we have a data corruption somewhere. There are many situations this could happen. It could be a mulfunctioning:
firewall, or
NAT, or
NIC device driver, or
NIC itself, or
switch/router along the way, or
...something else that corrupted the data in between the two SSH parties
Again, it could also be the SSH implementation itself but as with the "bad packet length" problem that's usually not the case. Note that all those corruptions assume that the TCP packet passes the checksum test but that can easily happen. The checksum is basically a sum of all 16 bit words in the TCP frame; see RFC 793 (Transmission Control Protocol) for the details.

具体网页地址是https://blogs.oracle.com/janp/entry/ssh_messages_code_bad_packet

我容器跨主机互通是使用ovs+vxlan,为了测试是否真为此问题,我使用下面方法进行测试。

1、测试环境

容器名       内网IP          宿主机
test_mac    172.16.2.114    A
test_mac_2  172.16.2.115    B
test_mac_3  172.16.2.116    A

在宿主机A的容器test_mac里生成3G测试文件

09:56:16 # dd if=/dev/zero of=/tmp/test.tgz bs=1G count=3
3+0 records in
3+0 records out
3221225472 bytes (3.2 GB) copied, 5.21114 s, 618 MB/s

2、测试另外宿主机B的跨主机容器数据同步情况

root@41255dbf85b4:/tmp
09:56:21 # scp  -P 22 172.16.2.114:/tmp/test.tgz .
root@172.16.2.114's password:
test.tgz                                                                                     3%   99MB  50.6MB/s   00:58 ETA
Corrupted MAC on input.
Disconnecting: Packet corrupt
lost connection

可以看到出现了问题。

3、测试通宿主机容器数据同步情况

09:59:50 # scp -P 22 172.16.2.114:/tmp/test.tgz .
root@172.16.2.114's password:
test.tgz                                                                                   100% 3072MB  80.8MB/s   00:38
root@5805f5017f89:/tmp

可以看到正常同步。

4、解决跨宿主机容器数据同步方法

先在宿主机B里获取容器test_mac_2的pid

[root@ip-10-10-125-10 ~]# docker inspect test_mac_2|grep -i pid"PidMode": "","Pid": 29416,

可以看到pid是29416

然后使用nsenter来设置容器的内网网卡eth1关闭校验和

nsenter --target 29416 --mount --uts --ipc --net --pid -- /bin/bash -c "ethtool -k eth1"

使用nsenter是因为此方法可以直接拥有最高权限来修改,如果直接在容器里输入会有下面错误

10:12:52 # ethtool -K eth0 tx off rx off
Cannot get device feature names: No such device
root@41255dbf85b4:/

下面是解决前eth1网卡信息

[root@ip-10-10-125-10 ~]# nsenter --target 29416 --mount --uts --ipc --net --pid -- /bin/bash -c "ethtool -k eth1"
Features for eth1:
rx-checksumming: on
tx-checksumming: ontx-checksum-ipv4: off [fixed]tx-checksum-ip-generic: ontx-checksum-ipv6: off [fixed]tx-checksum-fcoe-crc: off [fixed]tx-checksum-sctp: off [fixed]
scatter-gather: ontx-scatter-gather: ontx-scatter-gather-fraglist: on
tcp-segmentation-offload: ontx-tcp-segmentation: ontx-tcp-ecn-segmentation: ontx-tcp6-segmentation: on
udp-fragmentation-offload: on
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: on
tx-vlan-offload: on
ntuple-filters: off [fixed]
receive-hashing: off [fixed]
highdma: on
rx-vlan-filter: off [fixed]
vlan-challenged: off [fixed]
tx-lockless: on [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: on
tx-ipip-segmentation: on
tx-sit-segmentation: on
tx-udp_tnl-segmentation: on
tx-mpls-segmentation: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: on
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off [fixed]
tx-vlan-stag-hw-insert: on
rx-vlan-stag-hw-parse: on
rx-vlan-stag-filter: off [fixed]
busy-poll: off [fixed]

开始运行命令关闭校验和

[root@ip-10-10-125-10 ~]# nsenter --target 29416 --mount --uts --ipc --net --pid -- /bin/bash -c "ethtool -K eth1 tx off rx off "
Actual changes:
rx-checksumming: off
tx-checksumming: offtx-checksum-ip-generic: off
tcp-segmentation-offload: offtx-tcp-segmentation: off [requested on]tx-tcp-ecn-segmentation: off [requested on]tx-tcp6-segmentation: off [requested on]
udp-fragmentation-offload: off [requested on]

然后在查看一下eth1网卡信息

Features for eth1:
rx-checksumming: off
tx-checksumming: offtx-checksum-ipv4: off [fixed]tx-checksum-ip-generic: offtx-checksum-ipv6: off [fixed]tx-checksum-fcoe-crc: off [fixed]tx-checksum-sctp: off [fixed]
scatter-gather: ontx-scatter-gather: ontx-scatter-gather-fraglist: on
tcp-segmentation-offload: offtx-tcp-segmentation: off [requested on]tx-tcp-ecn-segmentation: off [requested on]tx-tcp6-segmentation: off [requested on]
udp-fragmentation-offload: off [requested on]
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: on
tx-vlan-offload: on
ntuple-filters: off [fixed]
receive-hashing: off [fixed]
highdma: on
rx-vlan-filter: off [fixed]
vlan-challenged: off [fixed]
tx-lockless: on [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: on
tx-ipip-segmentation: on
tx-sit-segmentation: on
tx-udp_tnl-segmentation: on
tx-mpls-segmentation: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: on
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off [fixed]
tx-vlan-stag-hw-insert: on
rx-vlan-stag-hw-parse: on
rx-vlan-stag-filter: off [fixed]
busy-poll: off [fixed]

可以很明显看到rx-checksumming与tx-checksumming都从on变为off了。

然后在宿主机B里使用test_mac_2进行数据同步宿主机A的test_mac数据

10:16:09 # scp  -P 22 172.16.2.114:/tmp/test.tgz .
root@172.16.2.114's password:
test.tgz                                                                                   100% 3072MB  46.6MB/s   01:06
root@41255dbf85b4:/

可以看到数据传输正常。

Docker跨主机容器互传数据问题及解决方法相关推荐

  1. Docker 跨主机容器网络通信 -- Flannel 实现

    一.简介 Flannel 是一种基于 overlay 网络的跨主机容器网络解决方案,也就是将 TCP 数据包封装在另一种网络包里面进行路由转发和通信,Flannel 是 CoreOS 开发,专门用于 ...

  2. docker跨主机集群之flannel

    0. 环境说明 CentOS7 etcd-v3.4.3-linux-amd64.tar.gz flannel-v0.11.0-linux-amd64.tar.gz 官方文档:https://githu ...

  3. Docker原生网络、自定义网络、Docker容器通信、跨主机容器网络

    Docker原生网络.自定义网络.Docker容器通信.跨主机容器网络 Docker原生网络 bridge Host none Docker自定义网络 自定义bridge overlay macvia ...

  4. docker 绑定固定ip 跨主机容器互访

    之前使用pipework 分配静态ip是暂时的,重启之后就会失效,并且使用pipework绑定的ip 物理机,虚拟机,docker容器的ip都在同一网段,这在生产环境是很困难的,下面使用docker自 ...

  5. Docker 跨主机网络方案分析

    PS:文章首发公众号,欢迎大家关注我的公众号:aCloudDeveloper,专注技术分享,努力打造干货分享平台,二维码在文末可以扫,谢谢大家. 上篇文章介绍了容器网络的单主机网络,本文将进一步介绍多 ...

  6. 两个云服务器怎么互传文件,两个云服务器互传数据

    两个云服务器互传数据 内容精选 换一换 云上容灾有三种场景,如表1所示.跨AZ容灾的方案如图1所示.该架构适用云上同城容灾,要求RPO等于0的场景.该方案下,RPO等于0,RTO小于30分钟.在平时业 ...

  7. 两部手机怎样才能把数据都传过来_新旧手机怎样互传数据?

    原标题:新旧手机怎样互传数据? 手机是人们工作.学习和生活中必不可少的工具,很多人的手机使用一段时间之后都会换新的,新手机虽然好用,但是旧手机里面的东西也很有价值.要想用新手机的同时保留旧手机的数据, ...

  8. 树莓派和Windows电脑互传数据方法

    树莓派和window怎么互传数据 一.安装软件filezilla.exe 1. 可以自己去网上找 2. 百度网盘:链接 提取码:n0q5 3. 打开filezilla 4. 点击快速连接即可

  9. vm 虚拟服务器 文件上传,vmware虚拟机怎么和主机之间互传文件?

    在使用Windows 10工作时会遇到形形色色的问题,比如虚拟机需要与主机之间互传文件.那么如何进行设置呢?下面小编与你分享具体步骤和方法. 工具/材料 Windows 10操作系统 操作方法 01启 ...

  10. docker跨主机网络——overlay与macvlan

    docker的跨主机网络 前言 这篇文件分两种方式介绍docker跨主机通信,overlay和macvlan,macvlan的方式给大家做个参考,生产环境下不推荐大家使用这种方式

最新文章

  1. 书写神器——markdown
  2. Redis的安装和部署
  3. ubuntu下载软件安装包
  4. 矩形做成翻页的效果html5,HTML5 在canvas中绘制矩形附效果图
  5. Gartner调查显示政府部门数字化转型尚处萌芽期
  6. ArcGIS10.1之crossdomain文件
  7. 最佳圆角字体,设计师的最爱
  8. 老兵不死:Radionomy正式宣布收购Winamp
  9. OC4J、UCP、CGI(引用)
  10. 二维码ZBar之ZBarReaderView
  11. 使用numpy构建卷积网络
  12. 59 | 测试专栏特别放送 | 答疑解惑第七期
  13. 用Markdown记笔记后转换成html
  14. 斐波那契数列c语言编程递归,C语言实现Fibonacci数列递归
  15. 不花里胡哨看电脑主板支持最大内存与频率
  16. flutter 带未读消息的底部导航
  17. mac安装linux时触控板不能用,macbookpro上装Deepin 20.2后wifi和触摸板不可用的解决
  18. Linux系统安全加固指南(万字长文)
  19. 《股票作手回忆录》书中的精髓:上世纪美国最伟大的交易员杰西·利弗莫尔带给我们的交易思想精华。
  20. 查看网段内所有ip设备

热门文章

  1. array在java_在Java中的ArrayLists之间进行转换
  2. python 京东 价格_python根据京东商品url获取产品价格
  3. DNN与微软同声传译系统背后的故事
  4. MongoDB 在windows shell环境下的基本操作和命令的使用示例(一)
  5. 【POJ 1182】食物链【“拓展域”并查集】
  6. 207.课程表(力扣leetcode) 博主可答疑该问题
  7. 101.对称二叉树(力扣leetcode) 博主可答疑该问题
  8. 172.阶乘后的零 (力扣leetcode) 博主可答疑该问题
  9. php实现先序、中序、后序遍历二叉树
  10. 利用ST MCU内部的基准参考电压监测电源电压及其它