Spring cloud在加入Config配置中心后,Eureka中的服务状态显示为UNKOUNW(1),Eureka的client端显示如下注册状态为204,重新注册。
Eureka服务端:
Eureka client端:
2018-11-02 15:16:13.715 [DiscoveryClient-HeartbeatExecutor-0] INFO com.netflix.discovery.DiscoveryClient - DiscoveryClient_CHINESENER/BigData:chinesener:8081 - registration status: 204
2018-11-02 15:16:23.722 [DiscoveryClient-HeartbeatExecutor-0] INFO com.netflix.discovery.DiscoveryClient - DiscoveryClient_CHINESENER/BigData:chinesener:8081 - Re-registering apps/CHINESENER
配置文件原来写在application.yml文件中,后来该写到了bootstrap.yml文件中。文件内容没有改变,如下:
eureka:
instance:
hostname: localhost
lease-expiration-duration-in-seconds: 30 # 续约到期时间(默认90秒)
lease-renewal-interval-in-seconds: 10 # 续约更新时间间隔(默认30秒)
client:
healthcheck:
enabled: true #改变eureka server对客户端健康检查方式
register-with-eureka: true #是否注册到eureka服务器
fetch-registry: true #是否可检索
service-url:
defaultZone: http://localhost:8080/eureka/ #服务中心
server:
tomcat:
max-http-post-size: -1 #设置接收任意大小的数据
port: 8081
#读取配置信息
spring:
application:
name: chinesener
cloud:
config:
label: master
profile: config-dev
#uri: http://localhost:8888/
discovery: #分布式环境下自动发现配置服务
enabled: true
serviceId: config-server
management:
security: false
虽然有问题,但是服务一直可用,但是总觉的不是很舒服,就找了一下解决方法。查到了这位大哥的博文,https://www.codercto.com/a/24528.html。
我将eureka.client.healthcheck.enabled=true注释掉,重启服务,ok,一切正常了!
后来想,既然是spring家族的问题,在spring官网上一定有答案,还真查找了,http://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html