인프런 커뮤니티 질문&답변

고성빈님의 프로필 이미지
고성빈

작성한 질문수

Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)

Order Microservice

안녕하세요 Orderservice 기동시 Userservice 죽는 문제 질문드립니다!

작성

·

904

0

userservice는 회원가입 조회 전부 정상으로 되는 것 확인하였습니다. 그런데 orderservice를 기동하니 userservice가 아래와 같은 로그를 보이고 죽어버리는데 어느부분을 체크해봐야 할까요.?

2021-09-14 07:38:00.171  INFO [user-service,ee9525de740db2ca,ee9525de740db2ca] 1 --- [o-auto-1-exec-4] c.e.userservice.service.UserServiceImpl  : Before call orders microservice
2021-09-14 07:38:00.323 DEBUG [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] c.e.u.client.OrderServiceClient          : [OrderServiceClient#getOrders] ---> GET http://order-service/order-service/d3349235-0486-4d66-aefc-a78306d4b931/orders HTTP/1.1
2021-09-14 07:38:00.324 DEBUG [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] c.e.u.client.OrderServiceClient          : [OrderServiceClient#getOrders] ---> END HTTP (0-byte body)
2021-09-14 07:38:00.702  WARN [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [oundedElastic-1] o.s.c.l.core.RoundRobinLoadBalancer      : No servers available for service: order-service
2021-09-14 07:38:00.705  WARN [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] .s.c.o.l.FeignBlockingLoadBalancerClient : Service instance was not resolved, executing the original request
2021-09-14 07:38:00.786  WARN [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [oundedElastic-1] o.s.c.l.core.RoundRobinLoadBalancer      : No servers available for service: order-service
2021-09-14 07:38:00.787  WARN [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] .s.c.o.l.FeignBlockingLoadBalancerClient : Service instance was not resolved, executing the original request
2021-09-14 07:38:00.789 DEBUG [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] c.e.u.client.OrderServiceClient          : [OrderServiceClient#getOrders] <--- ERROR UnknownHostException: order-service (463ms)
2021-09-14 07:38:00.791 DEBUG [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] c.e.u.client.OrderServiceClient          : [OrderServiceClient#getOrders] java.net.UnknownHostException: order-service
	at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
	at java.base/java.net.Socket.connect(Socket.java:631)
	at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:497)
	at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:600)
	at java.base/sun.net.www.http.HttpClient.<init>(HttpClient.java:246)
	at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:351)
	at java.base/sun.net.www.http.HttpClient.New(HttpClient.java:372)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1299)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1232)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1120)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:1051)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1653)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1577)
	at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
	at feign.Client$Default.convertResponse(Client.java:108)
	at feign.Client$Default.execute(Client.java:104)
	at org.springframework.cloud.sleuth.instrument.web.client.feign.TracingFeignClient.execute(TracingFeignClient.java:79)
	at org.springframework.cloud.sleuth.instrument.web.client.feign.LazyTracingFeignClient.execute(LazyTracingFeignClient.java:62)
	at org.springframework.cloud.openfeign.loadbalancer.LoadBalancerUtils.executeWithLoadBalancerLifecycleProcessing(LoadBalancerUtils.java:56)
	at org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.lambda$execute$2(RetryableFeignBlockingLoadBalancerClient.java:156)
	at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:329)
	at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:225)
	at org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient.execute(RetryableFeignBlockingLoadBalancerClient.java:103)
	at org.springframework.cloud.sleuth.instrument.web.client.feign.TraceRetryableFeignBlockingLoadBalancerClient.execute(TraceRetryableFeignBlockingLoadBalancerClient.java:79)
	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:119)
	at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:89)
	at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100)
	at jdk.proxy2/jdk.proxy2.$Proxy204.getOrders(Unknown Source)
	at com.example.userservice.service.UserServiceImpl.lambda$getUserByUserId$0(UserServiceImpl.java:106)
	at org.springframework.cloud.sleuth.instrument.circuitbreaker.TraceSupplier.get(TraceSupplier.java:51)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:831)

2021-09-14 07:38:00.792 DEBUG [user-service,ee9525de740db2ca,95105fb0dd901585] 1 --- [pool-3-thread-1] c.e.u.client.OrderServiceClient          : [OrderServiceClient#getOrders] <--- END ERROR
2021-09-14 07:38:00.841  INFO [user-service,ee9525de740db2ca,ee9525de740db2ca] 1 --- [o-auto-1-exec-4] c.e.userservice.service.UserServiceImpl  : After call orders microservice
2021-09-14 07:40:10.003  INFO [user-service,,] 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration

현재 도커 상태

CONTAINER ID   IMAGE                            COMMAND                  CREATED          STATUS                       PORTS                                                                                                                                                                                                         NAMES
9be9b53b37d3   larry39/order-service:1.0        "java -jar OrderServ…"   7 minutes ago    Up 7 minutes                                                                                                                                                                                                                               order-service
d3a1e0883b57   larry39/user-service:1.0         "java -jar UserServi…"   30 minutes ago   Exited (137) 6 minutes ago                                                                                                                                                                                                                 user-service
183615bc700a   larry39/apigateway-service:1.0   "java -jar Apigatewa…"   40 minutes ago   Up 40 minutes                0.0.0.0:8000->8000/tcp, :::8000->8000/tcp                                                                                                                                                                     apigateway-service
98bffac6b12a   larry39/discovery-service:1.0    "java -jar Discovery…"   45 minutes ago   Up 45 minutes                0.0.0.0:8761->8761/tcp, :::8761->8761/tcp                                                                                                                                                                     discovery-service
0759458ba188   larry39/config-service:1.0       "java -jar ConfigSer…"   49 minutes ago   Up 49 minutes                0.0.0.0:8888->8888/tcp, :::8888->8888/tcp                                                                                                                                                                     config-service
108c2f33d146   grafana/grafana                  "/run.sh"                5 hours ago      Up 5 hours                   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                                                                                                                                                     grafana
4fc3bf97b078   prom/prometheus                  "/bin/prometheus --c…"   5 hours ago      Up 5 hours                   0.0.0.0:9090->9090/tcp, :::9090->9090/tcp                                                                                                                                                                     prometheus
617edb00849d   openzipkin/zipkin                "start-zipkin"           6 hours ago      Up 6 hours (healthy)         9410/tcp, 0.0.0.0:9411->9411/tcp, :::9411->9411/tcp                                                                                                                                                           zipkin
2a036264380d   wurstmeister/zookeeper           "/bin/sh -c '/usr/sb…"   6 hours ago      Up 6 hours                   22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, :::2181->2181/tcp                                                                                                                                         kafka-docker_zookeeper_1
7e71d4ed33ef   larry39/my-mysql:1.0             "docker-entrypoint.s…"   7 hours ago      Up 7 hours                   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                                                                                                          mysql
bf1121f8849f   rabbitmq:management              "docker-entrypoint.s…"   29 hours ago     Up 29 hours                  0.0.0.0:4369->4369/tcp, :::4369->4369/tcp, 0.0.0.0:5671-5672->5671-5672/tcp, :::5671-5672->5671-5672/tcp, 15691-15692/tcp, 0.0.0.0:15671-15672->15671-15672/tcp, :::15671-15672->15671-15672/tcp, 25672/tcp   rabbitmq

혹시 몰라 제 github repository 도 첨부합니다.

https://github.com/seongbinko/spring-cloud (소스)

https://github.com/seongbinko/spring-cloud-config (설정파일)

 

답변 2

0

Dowon Lee님의 프로필 이미지
Dowon Lee
지식공유자

안녕하세요, 이도원입니다. 

올려주신 로그의 에러 메시지는 UnknownHostException으로 user-service에서 order-service로 주문 내역을 조회 할 때, feign-client를 사용하는데, 여기에서 order-service를 찾지 못하는 오류가 발생한 것 같습니다. eureka에 order-service가 정상작동 되었는지 확인해 보시고, 이상이 없다면, docker로 기동하기 전에 user-service와 order-service가 잘 연동되었는지도 확인해 보시기 바랍니다. 이 모든 것에 이상이 없다면, docker-compose로 기동했을 때, order-service와 user-service, service-discovery 등 모든 서비스들이 같은 network에서 기동되었는지 확인해 보시기 바랍니다. 

감사합니다. 

0

고성빈님의 프로필 이미지
고성빈
질문자

docker compose 파일은 github에 올라가지 못해서 여기에 남깁니다.

version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
networks:
my-network:
ipv4_address: 172.18.0.100
kafka:
# build: .
image: wurstmeister/kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 172.18.0.101
KAFKA_CREATE_TOPICS: "test:1:1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- zookeeper
networks:
my-network:
ipv4_address: 172.18.0.101
networks:
my-network:
name: ecommerce-network
고성빈님의 프로필 이미지
고성빈

작성한 질문수

질문하기