我有一个包含 2 个模块的 Spring 项目:Pets 和 Owners,每个模块都是从单个 MySQL 数据库获取数据的微服务。当我将这两者推送到具有 2 个任务的单个 Docker 容器中时——每个微服务 1 个——它们都启动并运行,并且这些任务被映射到不同的主机端口(32768 和 32769)。但是,当我访问 http://{elb-dns}/pet 时,我得到了 404,但是当我访问 http://{elb-dns}/owner 时,它返回了预期的数据。我了解到宠物任务被映射到错误的目标组,但不知道为什么。
创建 ECS 集群后,以下 AWS CLI“描述”命令输出如下:
aws ecs describe-clusters --cluster vets --region us-west-2
{
"clusters": [
{
"status": "ACTIVE",
"clusterName": "vets",
"registeredContainerInstancesCount": 3,
"pendingTasksCount": 0,
"runningTasksCount": 4,
"activeServicesCount": 2,
"clusterArn": "arn:aws:ecs:us-west-2:224265390743:cluster/vets"
}
],
"failures": []
}
aws elbv2 describe-target-groups --name vets0-tg --region us-west-2
{
"TargetGroups": [
{
"HealthCheckPath": "/",
"HealthCheckIntervalSeconds": 60,
"VpcId": "vpc-0540fe4c35343c7c9",
"Protocol": "HTTP",
"HealthCheckTimeoutSeconds": 30,
"HealthCheckProtocol": "HTTP",
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-west-2:224265390743:loadbalancer/app/vets-elb/5643eac9e4d51da0"
],
"UnhealthyThresholdCount": 3,
"HealthyThresholdCount": 5,
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets0-tg/8fec38deef74b8f1",
"Matcher": {
"HttpCode": "200"
},
"HealthCheckPort": "traffic-port",
"Port": 8080,
"TargetGroupName": "vets0-tg"
}
]
}
aws elbv2 describe-target-groups --name vets1-tg --region us-west-2
{
"TargetGroups": [
{
"HealthCheckPath": "/",
"HealthCheckIntervalSeconds": 60,
"VpcId": "vpc-0540fe4c35343c7c9",
"Protocol": "HTTP",
"HealthCheckTimeoutSeconds": 30,
"HealthCheckProtocol": "HTTP",
"LoadBalancerArns": [
"arn:aws:elasticloadbalancing:us-west-2:224265390743:loadbalancer/app/vets-elb/5643eac9e4d51da0"
],
"UnhealthyThresholdCount": 3,
"HealthyThresholdCount": 5,
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets1-tg/b4ca3cafcaebdc78",
"Matcher": {
"HttpCode": "200"
},
"HealthCheckPort": "traffic-port",
"Port": 8080,
"TargetGroupName": "vets1-tg"
}
]
}
aws ecs describe-task-definition --task-definition vets-rest-pet:25 --region us-west-2
{
"taskDefinition": {
"status": "ACTIVE",
"networkMode": "bridge",
"family": "vets-rest-pet",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
}
],
"volumes": [],
"taskRoleArn": "arn:aws:iam::224265390743:role/MicroECSTaskRole",
"taskDefinitionArn": "arn:aws:ecs:us-west-2:224265390743:task-definition/vets-rest-pet:25",
"containerDefinitions": [
{
"environment": [
{
"name": "SPRING_DATASOURCE_USERNAME",
"value": "***"
},
{
"name": "SERVICE_ENDPOINT",
"value": "***.us-west-2.elb.amazonaws.com"
},
{
"name": "SPRING_DATASOURCE_URL",
"value": "***"
},
{
"name": "SPRING_DATASOURCE_PASSWORD",
"value": "***"
},
{
"name": "SPRING_PROFILES_ACTIVE",
"value": "mysql"
}
],
"name": "vets-rest-pet",
"mountPoints": [],
"image": "224265390743.dkr.ecr.us-west-2.amazonaws.com/vets-rest-pet:latest",
"dockerLabels": {
"string": "string"
},
"cpu": 1024,
"portMappings": [
{
"protocol": "tcp",
"containerPort": 8080,
"hostPort": 0
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "vets",
"awslogs-group": "ECSLogGroup-vets"
}
},
"memory": 1024,
"essential": true,
"volumesFrom": []
}
],
"revision": 25
}
}
aws ecs describe-task-definition --task-definition vets-rest-owner:18 --region us-west-2
{
"taskDefinition": {
"status": "ACTIVE",
"networkMode": "bridge",
"family": "vets-rest-owner",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
}
],
"volumes": [],
"taskRoleArn": "arn:aws:iam::224265390743:role/MicroECSTaskRole",
"taskDefinitionArn": "arn:aws:ecs:us-west-2:224265390743:task-definition/vets-rest-owner:18",
"containerDefinitions": [
{
"environment": [
{
"name": "SPRING_DATASOURCE_USERNAME",
"value": "***"
},
{
"name": "SERVICE_ENDPOINT",
"value": "***.us-west-2.elb.amazonaws.com"
},
{
"name": "SPRING_DATASOURCE_URL",
"value": "***"
},
{
"name": "SPRING_DATASOURCE_PASSWORD",
"value": "***"
},
{
"name": "SPRING_PROFILES_ACTIVE",
"value": "mysql"
}
],
"name": "vets-rest-owner",
"mountPoints": [],
"image": "224265390743.dkr.ecr.us-west-2.amazonaws.com/vets-rest-owner:latest",
"dockerLabels": {
"string": "string"
},
"cpu": 1024,
"portMappings": [
{
"protocol": "tcp",
"containerPort": 8080,
"hostPort": 0
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-region": "us-west-2",
"awslogs-stream-prefix": "vets",
"awslogs-group": "ECSLogGroup-vets"
}
},
"memory": 1024,
"essential": true,
"volumesFrom": []
}
],
"revision": 18
}
}
aws elbv2 describe-load-balancers --region us-west-2
{
"LoadBalancers": [
{
"VpcId": "vpc-0540fe4c35343c7c9",
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:loadbalancer/app/vets-elb/5643eac9e4d51da0",
"State": {
"Code": "active"
},
"DNSName": "***.us-west-2.elb.amazonaws.com",
"SecurityGroups": [
"sg-09beda52a500a27fb"
],
"LoadBalancerName": "vets-elb",
"CreatedTime": "2018-03-27T02:55:14.510Z",
"Scheme": "internet-facing",
"Type": "application",
"CanonicalHostedZoneId": "Z1H1FL5HABSF5",
"AvailabilityZones": [
{
"SubnetId": "subnet-04bf10c7538cae458",
"ZoneName": "us-west-2c"
},
{
"SubnetId": "subnet-070b0cf7074abe6a4",
"ZoneName": "us-west-2b"
},
{
"SubnetId": "subnet-0a88aaf68def9cd1e",
"ZoneName": "us-west-2a"
}
]
}
]
}
aws elbv2 describe-listeners --load-balancer-arn arn:aws:elasticloadbalancing:us-west-2:224265390743:loadbalancer/app/vets-elb/5643eac9e4d51da0 --region us-west-2
{
"Listeners": [
{
"Protocol": "HTTP",
"DefaultActions": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets-elb-tg/fff73d84613d20d9",
"Type": "forward"
}
],
"LoadBalancerArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:loadbalancer/app/vets-elb/5643eac9e4d51da0",
"Port": 80,
"ListenerArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:listener/app/vets-elb/5643eac9e4d51da0/0ff4e63088aede1c"
}
]
}
aws elbv2 describe-rules --listener-arn arn:aws:elasticloadbalancing:us-west-2:224265390743:listener/app/vets-elb/5643eac9e4d51da0/0ff4e63088aede1c --region us-west-2
{
"Rules": [
{
"Priority": "363",
"Conditions": [
{
"Field": "path-pattern",
"Values": [
"/*"
]
}
],
"RuleArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:listener-rule/app/vets-elb/5643eac9e4d51da0/0ff4e63088aede1c/d8fdc1195564af14",
"IsDefault": false,
"Actions": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets0-tg/8fec38deef74b8f1",
"Type": "forward"
}
]
},
{
"Priority": "458",
"Conditions": [
{
"Field": "path-pattern",
"Values": [
"/*"
]
}
],
"RuleArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:listener-rule/app/vets-elb/5643eac9e4d51da0/0ff4e63088aede1c/40d6a6e2dd71eaa5",
"IsDefault": false,
"Actions": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets1-tg/b4ca3cafcaebdc78",
"Type": "forward"
}
]
},
{
"Priority": "default",
"Conditions": [],
"RuleArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:listener-rule/app/vets-elb/5643eac9e4d51da0/0ff4e63088aede1c/24df0f9b37383df2",
"IsDefault": true,
"Actions": [
{
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets-elb-tg/fff73d84613d20d9",
"Type": "forward"
}
]
}
]
}
我已经确认,当单独部署时,每个微服务都是独立工作的。我正在使用 Application Load Balancer,每个微服务都有自己的目标组。我不确定还有什么可以尝试或检查的。有没有人遇到过类似的问题?我还应该在哪里寻找线索?
更新 1
我将日志记录级别更改为 TRACE,并了解到所有 /pet 和 /owner 调用都被专门路由到 owner 任务。当我尝试 http://{elb-dns}/pet/1 时,以下日志来自所有者任务:
9:00.590 DEBUG 7 - [nio-8080-exec-8] o.s.b.w.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.connector.RequestFacade@446e699a
9:00.590 TRACE 7 - [nio-8080-exec-8] o.s.b.a.trace.WebRequestTraceFilter : Processing request GET /pet/1
9:00.590 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Bound request context to thread: org.apache.catalina.connector.RequestFacade@446e699a
9:00.590 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/pet/1]
9:00.590 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@29ef6856] in DispatcherServlet with name 'dispatcherServlet'
9:00.590 TRACE 7 - [nio-8080-exec-8] o.s.w.s.handler.SimpleUrlHandlerMapping : No handler mapping found for [/pet/1]
9:00.590 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping@2f162cc0] in DispatcherServlet with name 'dispatcherServlet'
9:00.590 DEBUG 7 - [nio-8080-exec-8] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /pet/1
9:00.591 DEBUG 7 - [nio-8080-exec-8] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/pet/1]
9:00.591 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@b40bb6e] in DispatcherServlet with name 'dispatcherServlet'
9:00.591 DEBUG 7 - [nio-8080-exec-8] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /pet/1
9:00.591 DEBUG 7 - [nio-8080-exec-8] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/pet/1]
9:00.591 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping@34a75079] in DispatcherServlet with name 'dispatcherServlet'
9:00.591 TRACE 7 - [nio-8080-exec-8] o.s.w.s.h.BeanNameUrlHandlerMapping : No handler mapping found for [/pet/1]
9:00.591 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping@841e575] in DispatcherServlet with name 'dispatcherServlet'
9:00.591 DEBUG 7 - [nio-8080-exec-8] o.s.d.r.w.BasePathAwareHandlerMapping : Looking up handler method for path /pet/1
9:00.591 DEBUG 7 - [nio-8080-exec-8] o.s.d.r.w.BasePathAwareHandlerMapping : Did not find handler method for [/pet/1]
9:00.591 DEBUG 7 - [nio-8080-exec-8] o.s.d.r.w.RepositoryRestHandlerMapping : Looking up handler method for path /pet/1
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.d.r.w.RepositoryRestHandlerMapping : Found 1 matching mapping(s) for [/pet/1] : [{[/{repository}/{id}],methods=[GET],produces=[application/hal+json]}]
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.d.r.w.RepositoryRestHandlerMapping : Did not find handler method for [/pet/1]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@346a361] in DispatcherServlet with name 'dispatcherServlet'
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/pet/1] are [\/**]
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/pet/1] are {}
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/pet/1] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@5471388b]]] and 1 interceptor
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter@94f6bfb]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@2cac4385]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter@186978a6]
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/pet/1] is: -1
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.r.ResourceHttpRequestHandler : Applying "invalid path" checks to path: pet/1
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : Resolving resource for request path "pet/1"
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : Checking location: ServletContext resource [/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : No match for location: ServletContext resource [/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [META-INF/resources/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [META-INF/resources/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [resources/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [resources/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [static/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [static/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : Checking location: class path resource [public/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.resource.PathResourceResolver : No match for location: class path resource [public/]
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.w.s.r.ResourceHttpRequestHandler : No matching resource found - returning 404
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
9:00.592 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@446e699a
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Successfully completed request
9:00.592 TRACE 7 - [nio-8080-exec-8] ationConfigEmbeddedWebApplicationContext : Publishing event in org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@77a567e1: ServletRequestHandledEvent: url=[/pet/1]; pet=[10.0.1.219]; method=[GET]; servlet=[dispatcherServlet]; session=[null]; user=[null]; time=[2ms]; status=[OK]
9:00.592 DEBUG 7 - [nio-8080-exec-8] o.s.b.w.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@446e699a
9:00.593 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Bound request context to thread: org.apache.catalina.core.ApplicationHttpRequest@6a03dc7
9:00.593 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
9:00.593 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping@29ef6856] in DispatcherServlet with name 'dispatcherServlet'
9:00.593 TRACE 7 - [nio-8080-exec-8] o.s.w.s.handler.SimpleUrlHandlerMapping : No handler mapping found for [/error]
9:00.593 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping@2f162cc0] in DispatcherServlet with name 'dispatcherServlet'
9:00.593 DEBUG 7 - [nio-8080-exec-8] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /error
9:00.593 DEBUG 7 - [nio-8080-exec-8] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/error]
9:00.593 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping@b40bb6e] in DispatcherServlet with name 'dispatcherServlet'
9:00.593 DEBUG 7 - [nio-8080-exec-8] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
9:00.593 TRACE 7 - [nio-8080-exec-8] s.w.s.m.m.a.RequestMappingHandlerMapping : Found 2 matching mapping(s) for [/error] : [{[/error],produces=[text/html]}, {[/error]}]
9:00.594 DEBUG 7 - [nio-8080-exec-8] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
9:00.594 DEBUG 7 - [nio-8080-exec-8] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'basicErrorController'
9:00.594 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.data.rest.webmvc.RepositoryRestHandlerAdapter@94f6bfb]
9:00.594 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter@2cac4385]
9:00.594 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/error] is: -1
9:00.594 DEBUG 7 - [nio-8080-exec-8] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
9:00.594 TRACE 7 - [nio-8080-exec-8] .s.t.s.TransactionSynchronizationManager : Bound value [org.springframework.orm.jpa.EntityManagerHolder@556e96bc] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@47c4ecdc] to thread [http-nio-8080-exec-8]
9:00.594 TRACE 7 - [nio-8080-exec-8] .w.s.m.m.a.ServletInvocableHandlerMethod : Invoking 'org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml' with arguments [org.apache.catalina.core.ApplicationHttpRequest@6a03dc7, org.apache.catalina.connector.ResponseFacade@1a8818e]
9:00.595 TRACE 7 - [nio-8080-exec-8] .w.s.m.m.a.ServletInvocableHandlerMethod : Method [org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml] returned [ModelAndView: reference to view with name 'error'; model is {timestamp=Sat Mar 24 9:00 GMT 2018, status=404, error=Not Found, message=No message available, path=/pet/1}]
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, text/html;q=0.8] based on Accept header types and producible media types [text/html])
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'error'
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView@7a8fa663] based on requested media type 'text/html'
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Rendering view [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView@7a8fa663] in DispatcherServlet with name 'dispatcherServlet'
9:00.595 TRACE 7 - [nio-8080-exec-8] o.s.util.PropertyPlaceholderHelper : Resolved placeholder 'timestamp'
9:00.595 TRACE 7 - [nio-8080-exec-8] o.s.util.PropertyPlaceholderHelper : Resolved placeholder 'error'
9:00.595 TRACE 7 - [nio-8080-exec-8] o.s.util.PropertyPlaceholderHelper : Resolved placeholder 'status'
9:00.595 TRACE 7 - [nio-8080-exec-8] o.s.util.PropertyPlaceholderHelper : Resolved placeholder 'message'
9:00.595 TRACE 7 - [nio-8080-exec-8] .s.t.s.TransactionSynchronizationManager : Removed value [org.springframework.orm.jpa.EntityManagerHolder@556e96bc] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@47c4ecdc] from thread [http-nio-8080-exec-8]
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.j.s.OpenEntityManagerInViewInterceptor : Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.s.orm.jpa.EntityManagerFactoryUtils : Closing JPA EntityManager
9:00.595 TRACE 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Cleared thread-bound request context: org.apache.catalina.core.ApplicationHttpRequest@6a03dc7
9:00.595 DEBUG 7 - [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Successfully completed request
9:00.595 TRACE 7 - [nio-8080-exec-8] ationConfigEmbeddedWebApplicationContext : Publishing event in org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@77a567e1: ServletRequestHandledEvent: url=[/error]; pet=[10.0.1.219]; method=[GET]; servlet=[dispatcherServlet]; session=[null]; user=[null]; time=[2ms]; status=[OK]
同样的调用不会在宠物任务中产生任何日志,这表明它没有被路由到容器中的正确任务。所以我仍然坚持这个问题。
更新 2
ELB 日志显示,对于 /pet 和 /owner,所有呼叫都被路由到同一个目标组。然而,/pet 应该被路由到一个 TG,/owner 应该被路由到另一个。需要明确的是,我有 3 个 TG:一个在容器端口 8080 上用于 /pet,一个在容器端口 8080 上用于 /owner,一个在容器端口 80 上接受 HTTP 请求。所有三个 TG 都在同一个 VPC 中。
http 03:48:22.439446Z app/vets-elb/ab3d7952d0ea2843 76.102.41.144:61442 10.0.12.74:32768 0.002 0.020 0.000 200 200 263 1259 "GET http://vets-elb-1925600148.us-west-2.elb.amazonaws.com:80/owner HTTP/1.1" "PostmanRuntime/6.4.1" - - arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets0-tg/16a5158616c45834 "Root=1-5ab71c06-4798a50a19129492453fd34c" "-" "-" 52
http 03:48:29.581797Z app/vets-elb/ab3d7952d0ea2843 76.102.41.144:61442 10.0.11.42:32768 0.000 0.006 0.000 404 404 263 319 "GET http://vets-elb-1925600148.us-west-2.elb.amazonaws.com:80/pet HTTP/1.1" "PostmanRuntime/6.4.1" - - arn:aws:elasticloadbalancing:us-west-2:224265390743:targetgroup/vets0-tg/16a5158616c45834 "Root=1-5ab71c0d-cff47d0a6bb893c0bc1b9b88" "-" "-" 52