当前位置: 首页 > 知识库问答 >
问题:

未在所有Eureka实例上注册微服务

华知
2023-03-14

Spring Boot版本:2.1.6.发行版

Spring Cloud版本:greenwich.sr1

目的是在一个集群中建立两个Eureka服务器实例,并将所有微服务注册到这两个服务器上,以实现HA。目前,我正在运行Ubuntu18.04的本地机器上测试这一点。

因此,正如在官方文档中提到的,我已经建立了对Eureka实例的点对点意识。在打开这两个Eureka服务器实例时,在Instance-1(端口8080)的仪表板上,在可用副本下显示Instance-2的名称,在Instance-2(端口8081)的仪表板上显示Instance-1的名称。到目前为止还好。

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

Eureka-1道具:

spring:
  application:
    name: eureka-naming-server
  jmx:
    default-domain: eureka-naming-server
eureka:
  client:
    service-url:
      defaultZone: http://eureka-server-2:8081/eureka-naming-server/eureka

    #register-with-eureka: false
    #fetch-registry: false
  instance:
    hostname: eureka-server-1

Eureka-2道具:

spring:
  application:
    name: eureka-naming-server
  jmx:
    default-domain: eureka-naming-server
eureka:
  client:
    service-url:
      defaultZone: http://eureka-server-1:8080/eureka-naming-server/eureka

    #register-with-eureka: false
    #fetch-registry: false
  instance:
    hostname: eureka-server-2

在微服务中,我使用以下依赖项:

<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
eureka:
  instance:
    metadata-map:
      configPath: /config
  client:
    service-url:
      defaultZone: http://localhost/eureka-naming-server/eureka
127.0.0.1 eureka-server-1

127.0.0.1 eureka-server-2
WARN 13748 --- [nio-8009-exec-3] Registered instance CONFIG-SERVER/192.168.1.16:config-server:8888 with status UP (replication=false)
WARN 13748 --- [nio-8009-exec-3] c.n.e.registry.AbstractInstanceRegistry  : DS: Registry: lease doesn't exist, registering resource: CONFIG-SERVER - 192.168.1.16:config-server:8888
2019-12-26 19:00:34.995  WARN 13748 --- [nio-8009-exec-3] c.n.eureka.resources.InstanceResource    : Not Found (Renew): CONFIG-SERVER - 192.168.1.16:config-server:8888

我已经尝试过这里和这里提到的建议。但似乎什么都不管用。

我还能错过什么呢?

共有1个答案

邹昊
2023-03-14

问题:

spring:
  application:
    name: eureka-naming-server

您为一个应用程序添加了相同的名称,所以它就像这样显示。

你需要把它改成,

spring:
  application:
    name: eureka-naming-server-1
spring:
  application:
    name: eureka-naming-server-2
 类似资料:
  • 我刚刚关注了下面这篇文章,https://spring.io/blog/2015/07/14/microservices-with-spring,但是我无法在尤里卡注册我的微服务。 customer-service.yml build . gradle for customer-service CustomerService.java 注册-server.yml

  • 我对docker,Spring框架的一切都很陌生…它们成功地在localhost环境中运行,现在我想把它们推送到docker中,但是总是给我错误,我在那里卡住了大约一周。有人能帮我弄清楚吗!!! 现在我有 eureka 服务器和云配置服务器服务,这是我的代码: 尤里卡服务器应用程序.yml 和 Dockerfile: 现在我有云配置服务器应用程序.yml:在这个文件中,我试图在github上备份它

  • 我的微服务的application.yml(客户端到Eureka) Eureka的application.yml 我在端口8762启动Eureka并在我的微服务中引用它。微服务未能在尤里卡注册。以下是微服务日志的例外情况。 现在最重要的是,如果我把Eureka服务器端口和微服务的Eureka注册端口改成8761的话,一切都很好!!!!微服务的注册正在进行。 在发布问题之前多次这样做,它的行为是这样

  • pom.xml 主应用程序类 Application.Properties eureka客户端设置 pom.xml Application.Properties 我在eureka-server仪表板(http://localhost:8761)中没有看到向Eureka server注册的micro-service-currency-exchange-service 为什么eureka客户端没有注册

  • 并编写了一个示例spring cloud etflix eureka maven项目,该项目在http://localhost:8761上运行良好 我在spring boot微服务主类上都使用了注释@EureKadisCoveryClient和@SpringBootApplication 我使用了注释@enableeurekaserver和@springbootapplication