1、Completed shut down of DiscoveryClient
问题:
在启动EurekaClient时总是启动完自己就停了,注册就更别提了,看日志提示“Completed shut down of DiscoveryClient”
2019-09-09 10:38:10.362 INFO 17032 --- [ main] com.imooc.ClientApplication : No active profile set, falling back to default profiles: default
2019-09-09 10:38:10.751 INFO 17032 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=a1768312-231d-3670-91cd-2778b6c7b9c1
2019-09-09 10:38:10.821 INFO 17032 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$142b350f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-09 10:38:10.835 WARN 17032 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-09-09 10:38:10.835 INFO 17032 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-09-09 10:38:10.839 WARN 17032 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2019-09-09 10:38:10.839 INFO 17032 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-09-09 10:38:13.072 INFO 17032 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2019-09-09 10:38:15.044 INFO 17032 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2019-09-09 10:38:15.165 INFO 17032 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2019-09-09 10:38:15.198 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2019-09-09 10:38:16.614 INFO 17032 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2019-09-09 10:38:16.615 INFO 17032 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2019-09-09 10:38:16.721 INFO 17032 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2019-09-09 10:38:16.722 INFO 17032 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2019-09-09 10:38:16.906 INFO 17032 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2019-09-09 10:38:17.407 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2019-09-09 10:38:17.569 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2019-09-09 10:38:17.572 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2019-09-09 10:38:17.574 INFO 17032 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-09-09 10:38:17.578 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1567996697577 with initial instances count: 1
2019-09-09 10:38:17.579 INFO 17032 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application APPLICATION-EUREAK-CLIENT with eureka with status UP
2019-09-09 10:38:17.580 INFO 17032 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1567996697580, current=UP, previous=STARTING]
2019-09-09 10:38:17.582 INFO 17032 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APPLICATION-EUREAK-CLIENT/localhost:Application-eureak-client:8001: registering service...
2019-09-09 10:38:17.598 INFO 17032 --- [ main] com.imooc.ClientApplication : Started ClientApplication in 12.535 seconds (JVM running for 13.201)
2019-09-09 10:38:17.601 INFO 17032 --- [ Thread-5] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application APPLICATION-EUREAK-CLIENT with eureka with status DOWN
2019-09-09 10:38:17.601 WARN 17032 --- [ Thread-5] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1567996697601, current=DOWN, previous=UP]
2019-09-09 10:38:17.606 INFO 17032 --- [ Thread-5] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2019-09-09 10:38:17.625 INFO 17032 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APPLICATION-EUREAK-CLIENT/localhost:Application-eureak-client:8001 - registration status: 204
2019-09-09 10:38:17.626 INFO 17032 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APPLICATION-EUREAK-CLIENT/localhost:Application-eureak-client:8001: registering service...
2019-09-09 10:38:17.632 INFO 17032 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APPLICATION-EUREAK-CLIENT/localhost:Application-eureak-client:8001 - registration status: 204
2019-09-09 10:38:17.633 INFO 17032 --- [ Thread-5] com.netflix.discovery.DiscoveryClient : Unregistering ...
2019-09-09 10:38:17.647 INFO 17032 --- [ Thread-5] com.netflix.discovery.DiscoveryClient : DiscoveryClient_APPLICATION-EUREAK-CLIENT/localhost:Application-eureak-client:8001 - deregister status: 200
2019-09-09 10:38:17.661 INFO 17032 --- [ Thread-5] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
解决:
pom中添加web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2、EurekaServer明明修改了端口号还总出现默认端口“8761”
原因:
是因为yml文件中我没有使用_defaultZone去覆盖默认值_
解决:
修改前的配置:
server:
port: 7001
eureka:
instance:
hostname: eureka7001.com #eureka服务端的实例名称
client:
register-with-eureka: false
fetch-registry: false
修改后的配置:
server:
port: 7001
eureka:
instance:
hostname: eureka7001.com #eureka服务端的实例名称
client:
service-url:
defaultZone: http://eureka7001.com/eureka/
register-with-eureka: false
fetch-registry: false
3、EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY’RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.
简单解释:
不停的重启可能会导致client应用出现此警告,
Eureka Server端和Eureka Client端他们之间采用的是心跳的机制,server端会不停的去检查client端是否上线存活,在一定的时间会统计出它的上线率(即一个比率),当低于某个比率时就会提示“EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY’RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE”。
意思就是你这个client上线率太低了,我现在可能都不知道你是上线还是下线,那怎么办呢,我就当做你是上线的(这其实是一种自我保护的模式)
建议:
在开发环境可以把这个给关闭,避免以后你要来调这个微服务的时候,展示的在线,实际是下线状态
eureka:
server:
enable-self-preservation: false