本文介绍了尤里卡检测服务状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

我们将Spring Cloud Netflix与Eureka一起用作服务发现,使用Zuul代理服务并对其进行负载均衡。

We are using Spring Cloud Netflix with Eureka as the service discovery and Zuul for proxying the services and load balance them.

微服务使用NodeJS实现,并使用NPM模块在Eureka注册和介于两者之间的自定义层处理配置和所有微服务通用的东西。

The microservices are implemented using NodeJS and are registered at Eureka using the NPM module eureka-js-client and a custom layer in between that handles the configuration and stuff that is generic for all microservices.

问题

问题是Eureka无法识别是否有一项服务出现故障。这是一个问题,因为我们有一个带有自动部署的开发基础架构,每次重新部署并重新启动不同端口上的微服务而无需重新启动Eureka(和Zuul)。

The problem is that Eureka does not recognize if one service goes down. This is a problem as we are having a development infrastructure with autodeployment that redeploys and restarts the microservices on different ports each time without restarting Eureka (and Zuul).

因此虽然我们有一个微服务的十个或更多个实例,其中只有一个已启动,但所有被认为都是 UP

Therefore after a while we have ten or more instances of one microservice where only one is up but all are recognized as beeing UP.

解决方案方法


  1. 我试过设置客户端较小的 heartbeatInterval 但这没有帮助。

我尝试设置在服务器上更新了updalThresholdUpdateIntervalMs ,但这也无济于事。

I tried setting the renewalThresholdUpdateIntervalMs on the server lesser but that does not help either.

更多令人沮丧,无助的财产尝试...

Many more frustrating, non-helping property tries…






问题

如何配置Eureka驱逐实例或将状态设置为 DOWN 不在re中发送心跳的实例不合时宜的时间(不是30分钟左右)?

How do I configure Eureka to evict instances or to set status to DOWN of the instances that do not send a heartbeat in a reasonable time (not 30 minutes or so)?

代码片段

服务器本身不包含可提及的代码(只需使用Spring Cloud Starter启动Eureka服务器的几个注释)。

The server itself does not contain mentionable code (just a few annotations to start the Eureka server using Spring Cloud Starter).

Eureka服务器的配置(我已经删除了所有非工作尝试):

The configuration of the Eureka server (I have removed all non-working tries):

server:
  port: 8761

spring:
  cloud:
    client:
      hostname: localhost

eureka:
  instance:
    address: 127.0.0.1
    hostname: ${spring.cloud.client.hostname}

客户发送到服务器的配置(使用):

The client configuration that is sent to the server (using eureka-js-client):

{
    instance : {
        instanceId : `${CONFIG.instance.address}:${CONFIG.instance.name}:${CONFIG.instance.port}`,
        app : CONFIG.instance.name,
        hostName : CONFIG.instance.host,
        ipAddr : CONFIG.instance.address,
        port : {
            '$' : CONFIG.instance.port,
            '@enabled' : true
        },
        homePageUrl : `http://${CONFIG.instance.host}:${CONFIG.instance.port}/`,
        statusPageUrl : `http://${CONFIG.instance.host}:${CONFIG.instance.port}/info`,
        healthCheckUrl : `http://${CONFIG.instance.host}:${CONFIG.instance.port}/health`,
        vipAddress : CONFIG.instance.name,
        secureVipAddress : CONFIG.instance.name,
        dataCenterInfo : {
            '@class' : 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
            name : 'MyOwn'
        }
    },
    eureka : {
        host : CONFIG.eureka.host,
        port : CONFIG.eureka.port,
        servicePath : CONFIG.eureka.servicePath || '/eureka/apps/',
        healthCheckInterval : 5000
    }
}


推荐答案

Eureka拥有'自我保护'模式。如果少于85%的实例心跳正在注册,则不会驱逐任何实例。您应该能够在尤里卡仪表板上看到警告。

Eureka has a 'self preservation' mode. Where if less than 85% of instances heartbeats are registering, it will not evict any instances. You should be able to see a warning on the eureka dashboard.

这篇关于尤里卡检测服务状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 11:52