Контейнер не регистрируется в сервисе eureka
Я использую Docker Toolbox
и Oracle VM
это идет с.
Автоматическая регистрация отлично работает снаружи docker
, Когда я запускаю их как container
Я могу просмотреть их оба, используя 192.168.99.100:8761
а также 192.168.99.100:8080
в VM
браузер. Это просто регистрация client
на eureka-service
который не работает.
Я также пытался связать их, используя network
и когда я inspect
network
это показывает мне, что оба контейнера находятся в network
, Но клиент все равно не регистрируется в eureka-service
,
ЭВРИКА-СЕРВИС
application.yml:
server:
port: 8761
eureka:
instance:
prefer-ip-address: true
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://192.168.99.100:8761/
bootstrap.yml:
spring:
application:
name: eureka-service
МИКРОСЕРВИС (КЛИЕНТ)
application.properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/shop
spring.datasource.username=shop
spring.datasource.password=shop
server.port=8080
application.yml
server:
port: 8080
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://192.168.99.100:8761/
//IP of the VM:EUREKA PORT
docker-compose.yml
spring:
jpa:
database: MYSQL
hibernate:
ddl-auto: validate
datasource:
url: jdbc:mysql://mysql:3306/shop
username: shop
password: shop
driver-class-name: com.mysql.jdbc.Driver
1 ответ
Установите уровень журнала в info, и, пожалуйста, проверяйте журналы приложения при запуске приложения, обратите внимание на эти журналы:
2018-03-26 17:00:42.618 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Disable delta property : false
2018-03-26 17:00:42.618 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Single vip registry refresh property : null
2018-03-26 17:00:42.619 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Force full registry fetch : false
2018-03-26 17:00:42.619 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Application is null : false
2018-03-26 17:00:42.619 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Registered Applications size is zero : true
2018-03-26 17:00:42.619 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Application version is -1: true
2018-03-26 17:00:42.619 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Getting all instance registry info from the eureka server
2018-03-26 17:00:42.785 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: The response status is 200
2018-03-26 17:00:42.786 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Starting heartbeat executor: renew interval is: 5
2018-03-26 17:00:42.788 INFO [,] [10460] [main] com.netflix.discovery.InstanceInfoReplicator: InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-03-26 17:00:42.792 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Discovery Client initialized at timestamp 1522054842792 with initial instances count: 1
2018-03-26 17:00:42.822 INFO [,] [10460] [main] org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry: Registering application service-testServerConsumer with eureka with status UP
2018-03-26 17:00:42.823 INFO [,] [10460] [main] com.netflix.discovery.DiscoveryClient: Saw local status change event StatusChangeEvent [timestamp=1522054842823, current=UP, previous=STARTING]
2018-03-26 17:00:42.826 INFO [,] [10460] [DiscoveryClient-InstanceInfoReplicator-0] com.netflix.discovery.DiscoveryClient: DiscoveryClient_SERVICE-TESTSERVERCONSUMER/10.234.97.21:service-testServerConsumer:8101: registering service...
2018-03-26 17:00:42.881 INFO [,] [10460] [DiscoveryClient-InstanceInfoReplicator-0] com.netflix.discovery.DiscoveryClient: DiscoveryClient_SERVICE-TESTSERVERCONSUMER/10.234.97.21:service-testServerConsumer:8101 - registration status: 204
Проверьте, если статус регистрации 204.
Если не найден, пожалуйста, проверьте проблему с сетью и, если eureka доступна, если вы наблюдаете это:
2018-03-26 17:03:50.048 WARN [,] [1648] [DiscoveryClient-InstanceInfoReplicator-0] com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient: Request execution failed with message: java.net.ConnectException: Connection refused: connect
2018-03-26 17:03:50.048 WARN [,] [1648] [DiscoveryClient-InstanceInfoReplicator-0] com.netflix.discovery.DiscoveryClient: DiscoveryClient_SERVICE-TESTSERVERCONSUMER/10.234.97.21:service-testServerConsumer:8101 - registration failed Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:798) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:88) [eureka-client-1.6.2.jar:1.6.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_144]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_144]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_144]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
2018-03-26 17:03:50.049 WARN [,] [1648] [DiscoveryClient-InstanceInfoReplicator-0] com.netflix.discovery.InstanceInfoReplicator: There was a problem with the instance info replicator
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:111) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:798) ~[eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:104) [eureka-client-1.6.2.jar:1.6.2]
at com.netflix.discovery.InstanceInfoReplicator$1.run(InstanceInfoReplicator.java:88) [eureka-client-1.6.2.jar:1.6.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_144]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_144]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_144]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
Чтобы проверить, доступна ли эврика, если ваша эврика запущена в весеннем облаке, пожалуйста, выполните curl http://192.168.99.100:8761/eureka/apps
чтобы увидеть, можете ли вы получить список серверов.