Docker запускается очень медленно и получает исключения, используя docker compose
Обновление: это работает довольно хорошо, когда я использую network
и связать их один за другим и запустить их потом! Это просто не работает при использовании docker-compose
,
я использую eureka discovery service
а также zuul
, У меня всего 4 микросервиса. Как только я запускаю их, они пытаются зарегистрироваться eureka service
но они терпят неудачу в этом. Пока они пытаются зарегистрироваться на eureka-service
они исключения: Request execution error
(увидеть ниже). Через некоторое время они регистрируют себя в большинстве случаев, но все еще продолжают выдавать исключения.
docker-compose.yml
version: '3'
services:
eureka-service:
image: eureka-service
ports:
- 8761:8761
article-service:
image: articlemicroservice
depends_on:
- mysql
ports:
- 8080:8080
customer-service:
image: customermicroservice
depends_on:
- mysql
ports:
- 8082:8082
order-service:
image: ordermicroservice
depends_on:
- mysql
ports:
- 8084:8084
shop-service:
image: shopmicroservice
depends_on:
- mysql
ports:
- 8083:8083
gateway-service:
image: gateway
depends_on:
- mysql
ports:
- 8090:8090
mysql:
image: mysql:5.7
depends_on:
- eureka-service
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: shop
MYSQL_USER: shop
MYSQL_PASSWORD: shop
volumes:
- mysqltest:/var/lib/mysql
volumes:
mysqltest:
driver: local
эврика сервис
application.yml
server:
port: 8761
eureka:
instance:
prefer-ip-address: true
client:
#registerWithEureka: false
#fetchRegistry: false
serviceUrl:
defaultZone: http://192.168.99.100:8761/
типичное микросервисное приложение.
application.yml
server:
port: 8082
eureka:
client:
#registerWithEureka: true
#fetchRegistry: true
serviceUrl:
defaultZone: http://eureka-service:8761/eureka/
исключения
shop-service_1 | 2018-03-26 08:21:20.188 INFO 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SHOPMICROSERVICE/3a1143f7775d:shopmicroservice:8083: registering service...
shop-service_1 | 2018-03-26 08:21:28.235 ERROR 1 --- [nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error
shop-service_1 |
shop-service_1 | com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out
shop-service_1 | at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
shop-service_1 | at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar!/:1.19.1]
shop-service_1 | at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.1.jar!/:1.19.1]
shop-service_1 | at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.1.jar!/:1.19.1]
shop-service_1 | at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.1.jar!/:1.19.1]
shop-service_1 | at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570) ~[jersey-client-1.19.1.jar!/:1.19.1]
shop-service_1 | at com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.register(AbstractJerseyEurekaHttpClient.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:119) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
shop-service_1 | at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
shop-service_1 | Caused by: java.net.SocketTimeoutException: Read timed out
shop-service_1 | at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_111]
shop-service_1 | at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_111]
shop-service_1 | at java.net.SocketInputStream.read(SocketInputStream.java:170) ~[na:1.8.0_111]
shop-service_1 | at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_111]
shop-service_1 | at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:161) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:278) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:286) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:230) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) ~[httpcore-4.4.9.jar!/:4.4.9]
shop-service_1 | at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.5.jar!/:4.5.5]
shop-service_1 | at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar!/:1.19.1]
shop-service_1 | ... 29 common frames omitted
shop-service_1 |
shop-service_1 | 2018-03-26 08:21:28.260 WARN 1 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: java.net.SocketTimeoutException: Read timed out
shop-service_1 | 2018-03-26 08:21:28.264 WARN 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SHOPMICROSERVICE/3a1143f7775d:shopmicroservice:8083 - registration failed Cannot execute request on any known server
shop-service_1 |
shop-service_1 | com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:829) ~[eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) [eureka-client-1.8.6.jar!/:1.8.6]
shop-service_1 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
shop-service_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
shop-service_1 | at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]
1 ответ
Попробуйте изменить Eureka's application.yml на:
eureka:
instance:
hostname: localhost
ip-address: 127.0.0.1
server:
enable-self-preservation: false
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Клиентская часть, в моем случае, выглядит так:
eureka:
client:
serviceUrl:
defaultZone: http://localhost:9999/eureka/
instance:
preferIpAddress: true
Нужно иметь в виду еще одну вещь - даже если в вашем файле компоновки Docker есть "disabled_on:", Docker не ждет, когда служба в этом контейнере станет фактически доступной, поэтому нормально видеть несколько исключений от клиентов Eureka при запуске. Если это беспокоит, вы посмотрите на это