1

运行服务命令:

docker service create -d \
    -p 8080:8080 \
    --mount type=bind,source=/etc/localtime,target=/etc/localtime \
    --mount type=bind,source=/etc/timezone,target=/etc/timezone \
    --mount type=bind,source=/home/test/docker/manager,target=/root \
    --network test-network \
    --workdir /root \
    --name test-manager \
    --replicas 2 \
    --limit-cpu 2 \
    --limit-memory 4G \
    java:8 java -Dspring.profiles.active=$PROFILE -jar -Xms512m -Xmx4096m /root/target/test-manager.jar

服务启动后,我用 测试了服务curl 192.168.2.48:8080/info,50% 的请求不起作用。docker exec -it xxx bash使用、 usedcurl 10.0.1.6:8080/info和输入容器curl 10.0.1.7:8080/info,发现所有结果都正常。但是如果我多次重新启动上述服务,有时,所有请求都可以完全正常工作。

网络检查

nc -vuz 192.168.2.48  4789
nc -vz 192.168.2.48  2377
nc -vuz 192.168.2.48  7946
nc -vz 192.168.2.48  7946

都成功了。

结果docker info

Containers: 4
 Running: 3
 Paused: 0
 Stopped: 1
Images: 25
Server Version: 17.06.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 102
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: tdc32kn0n6bwcz32ljvprcmq0
 Is Manager: true
 ClusterID: hdyakushxu1c6rsk2cml7b0l3
 Managers: 2
 Nodes: 2
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Root Rotation In Progress: false
 Node Address: 192.168.2.47
 Manager Addresses:
  192.168.2.47:2377
  192.168.2.48:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-92-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.78GiB
Name: ubuntu-qgsp01
ID: RP4U:E3PW:AU5R:BLD2:2QDL:DA25:GY2P:YV67:IR2F:GEBZ:XVX3:XC72
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://20agqwyc.mirror.aliyuncs.com/
Live Restore Enabled: false

怀疑是网络负载均衡或者vip导致的问题,某个节点无法到达,所以服务被挂了。但是,如果我在容器中 ping 另一个,我发现网络正在工作。我感到很困惑。

这个问题困扰了我很久,希望有人能帮助我。

4

0 回答 0