我不太清楚如何调查这个问题,基本上我使用如下命令为swarm部署了一组服务:
docker-compose -f docker-compose-swarm.yml config | docker stack deploy -c testing1
。
这是一个单节点集群(在一台机器上)。
为什么每一秒请求都无法路由?
telnet 127.0.0.1 8091
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
^C^C^CConnection closed by foreign host.
第二次尝试:
telnet 127.0.0.1 8091
Trying 127.0.0.1...
telnet: Unable to connect to remote host: No route to host
在docker-compose-swarm.yml
内我使用了一个网络并定义为:
networks:
navigator-imagegallery-network:
driver: overlay
其他调试信息:
第一次请求时tcpdump(成功):
sudo tcpdump -v -i any tcp port 8091
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
16:13:17.573503 IP (tos 0x0, ttl 64, id 1247, offset 0, flags [DF], proto TCP (6), length 60)
archamd.60974 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0x078a), seq 831371862, win 43690, options [mss 65495,sackOK,TS val 2928057139 ecr 0,nop,wscale 7], length 0
16:13:17.573516 IP (tos 0x0, ttl 64, id 1247, offset 0, flags [DF], proto TCP (6), length 60)
archamd.60974 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0x078a), seq 831371862, win 43690, options [mss 65495,sackOK,TS val 2928057139 ecr 0,nop,wscale 7], length 0
16:13:17.573603 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto TCP (6), length 60)
172.30.0.2.jamlink > archamd.60974: Flags [S.], cksum 0x586e (incorrect -> 0x44e0), seq 623836494, ack 831371863, win 27960, options [mss 1410,sackOK,TS val 1733128342 ecr 2928057139,nop,wscale 7], length 0
16:13:17.573603 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto TCP (6), length 60)
172.30.0.2.jamlink > localhost.localdomain.60974: Flags [S.], cksum 0x2b50 (incorrect -> 0x71fe), seq 623836494, ack 831371863, win 27960, options [mss 1410,sackOK,TS val 1733128342 ecr 2928057139,nop,wscale 7], length 0
16:13:17.573621 IP (tos 0x0, ttl 64, id 1248, offset 0, flags [DF], proto TCP (6), length 52)
archamd.60974 > 172.30.0.2.jamlink: Flags [.], cksum 0x5866 (incorrect -> 0xdf5c), ack 1, win 342, options [nop,nop,TS val 2928057139 ecr 1733128342], length 0
16:13:17.573623 IP (tos 0x0, ttl 64, id 1248, offset 0, flags [DF], proto TCP (6), length 52)
archamd.60974 > 172.30.0.2.jamlink: Flags [.], cksum 0x5866 (incorrect -> 0xdf5c), ack 1, win 342, options [nop,nop,TS val 2928057139 ecr 1733128342], length 0
16:13:17.573711 IP (tos 0x0, ttl 64, id 1249, offset 0, flags [DF], proto TCP (6), length 138)
archamd.60974 > 172.30.0.2.jamlink: Flags [P.], cksum 0x58bc (incorrect -> 0xe5f0), seq 1:87, ack 1, win 342, options [nop,nop,TS val 2928057139 ecr 1733128342], length 86
第二次请求时tcpdump(失败):
sudo tcpdump -v -i any tcp port 8091
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
16:14:33.896311 IP (tos 0x0, ttl 64, id 17252, offset 0, flags [DF], proto TCP (6), length 60)
archamd.32944 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0xeed3), seq 2620107720, win 43690, options [mss 65495,sackOK,TS val 2928133462 ecr 0,nop,wscale 7], length 0
16:14:33.896324 IP (tos 0x0, ttl 64, id 17252, offset 0, flags [DF], proto TCP (6), length 60)
archamd.32944 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0xeed3), seq 2620107720, win 43690, options [mss 65495,sackOK,TS val 2928133462 ecr 0,nop,wscale 7], length 0
16:14:34.939687 IP (tos 0x0, ttl 64, id 17253, offset 0, flags [DF], proto TCP (6), length 60)
archamd.32944 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0xeac0), seq 2620107720, win 43690, options [mss 65495,sackOK,TS val 2928134505 ecr 0,nop,wscale 7], length 0
16:14:34.939702 IP (tos 0x0, ttl 64, id 17253, offset 0, flags [DF], proto TCP (6), length 60)
archamd.32944 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0xeac0), seq 2620107720, win 43690, options [mss 65495,sackOK,TS val 2928134505 ecr 0,nop,wscale 7], length 0
16:14:36.987820 IP (tos 0x0, ttl 64, id 17254, offset 0, flags [DF], proto TCP (6), length 60)
archamd.32944 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0xe2bf), seq 2620107720, win 43690, options [mss 65495,sackOK,TS val 2928136554 ecr 0,nop,wscale 7], length 0
16:14:36.987829 IP (tos 0x0, ttl 64, id 17254, offset 0, flags [DF], proto TCP (6), length 60)
archamd.32944 > 172.30.0.2.jamlink: Flags [S], cksum 0x586e (incorrect -> 0xe2bf), seq 2620107720, win 43690, options [mss 65495,sackOK,TS val 2928136554 ecr 0,nop,wscale 7], length 0
docker version
的输出:
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.10
Git commit: 0520e24302
Built: Fri Mar 23 01:47:41 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.10
Git commit: 0520e24302
Built: Fri Mar 23 01:48:12 2018
OS/Arch: linux/amd64
Experimental: false
搬运工-撰写-swarm.yml
version: '3'
services:
proxy-nginx:
container_name: 'proxy-nginx'
image: stuartshay/navigator-identity-proxy:development
depends_on:
- api-imagegallery
- api-navigator-identity
ports:
- "8101:8101"
- "8091:8091"
- "8081:8081"
volumes:
- nginx-log-volume:/var/log/nginx/
networks:
- navigator-imagegallery-network
api-imagegallery:
container_name: 'gcapi-imagegallery'
image: stuartshay/imagegallery-api:2.0-local
environment:
ASPNETCORE_ENVIRONMENT: Docker
DB_SERVER: database
SA_PASSWORD: ${SA_PASSWORD}
openIdConnectConfiguration:authority : ${AUTHORITY}
depends_on:
- database
volumes:
- www-root-volume:/publish/wwwroot
networks:
- navigator-imagegallery-network
api-navigator-identity:
container_name: 'gcapi-navigator-identity'
image: stuartshay/navigator-identity-api:1.1.5-local
environment:
ASPNETCORE_ENVIRONMENT: Docker
DB_SERVER: database
SA_PASSWORD: ${SA_PASSWORD}
AuthClients:ImageGalleryApi : ${IMAGE_GALLERY_API}
AuthClients:ImageGalleryClient : ${IMAGE_GALLERY_CLIENT}
networks:
- navigator-imagegallery-network
config-identityserverdb:
container_name: 'gcconfig-identityserverdb'
image: stuartshay/navigator-identity-configuration:2.1-build
environment:
ASPNETCORE_ENVIRONMENT: Staging
DB_SERVER: database
SA_PASSWORD: ${SA_PASSWORD}
command: "/wait_for_it.sh -h database -p 1433 -t 0 -- dotnet NavigatorIdentity.Configuration.IdentityServerDataDB.dll"
depends_on:
- database
networks:
- navigator-imagegallery-network
redis:
container_name: 'gcredis'
image: stuartshay/navigator-identity-redis:development
restart: always
healthcheck:
test: ["CMD", "redis-cli","ping"]
ports:
- "6379:6379"
volumes:
- redis-data-volume:/var/lib/redis
restart: always
networks:
- navigator-imagegallery-network
database:
container_name: 'gcdatabase'
hostname: database
image: "stuartshay/navigator-identity-sqlserver:2017-CU5"
environment:
SA_PASSWORD: ${SA_PASSWORD}
healthcheck:
test: sqlcmd -S database -U SA -P ${SA_PASSWORD} -Q 'select 1'
volumes:
- sql-backup-volume:/backup
ports:
- "1433:1433"
depends_on:
- mail
networks:
- navigator-imagegallery-network
mail:
container_name: 'gcmail'
hostname: mail
image: mailhog/mailhog
ports:
- "8025:8025"
networks:
- navigator-imagegallery-network
volumes:
nginx-log-volume:
sql-data-volume:
sql-backup-volume:
www-root-volume:
redis-data-volume:
networks:
navigator-imagegallery-network:
driver: overlay