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

Eureka对等感知示例不起作用

葛永丰
2023-03-14

我在运行Eureka服务器示例时面临问题,以理解对等感知的概念。我有以下尤里卡服务:

package com.micro.eurekaserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableDiscoveryClient
@EnableEurekaServer
public class EurekaServerMicroServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServerMicroServiceApplication.class, args);
    }
}

application.yml

 ---
spring:
  profiles: peer1
server:
  port: 8761
eureka:
  instance:
    hostname: peer1
  client:
    serviceUrl:
      defaultZone: http://peer2:8762/eureka/

---
spring:
  profiles: peer2
server:
  port: 8762
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/
spring:
  application:
    name: eureka
127.0.0.1   peer1
127.0.0.1   peer2
localhost   peer1
localhost   peer2
com.netflix.discovery.DiscoveryClient    : Can't contact any eureka nodes - possibly a security group issue?

com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.jar:1.19]
    at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.jar:1.19]
    at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.3.7.jar:1.3.7]
    at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.jar:1.19]
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.jar:1.19]
    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) ~[jersey-client-1.19.jar:1.19]
    at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) ~[jersey-client-1.19.jar:1.19]
    at com.netflix.discovery.DiscoveryClient.getUrl(DiscoveryClient.java:1802) [eureka-client-1.3.7.jar:1.3.7]
    at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1546) [eureka-client-1.3.7.jar:1.3.7]
    at com.netflix.discovery.DiscoveryClient.makeRemoteCallWithFollowRedirect(DiscoveryClient.java:1460) [eureka-client-1.3.7.jar:1.3.7]
    at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1443) [eureka-client-1.3.7.jar:1.3.7]
    at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1394) [eureka-client-1.3.7.jar:1.3.7]

2016-03-26 12:23:09.963 ERROR 4940 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EUREKA/KHUJEMA-PC:eureka - was unable to send heartbeat!

com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
    at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.jar:1.19]
    at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.jar:1.19]
    at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.3.7.jar:1.3.7]
    at com.sun.jersey.api.client.Client.handle(Client.java:652) ~[jersey-client-1.19.jar:1.19]
    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) ~[jersey-client-1.19.jar:1.19]

我在日志中还注意到tomcat嵌入式服务器是在端口8080而不是8761/8762上启动的,不知道为什么?

请救命!

共有1个答案

樊腾
2023-03-14

尝试从应用程序.java中删除@EnableDiscoveryClient。我的是这样的:

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
 类似资料:
  • 我使用Spring Cloud Netflix构建了一个Eureka服务器。服务器正在工作,因此我目前正在尝试添加第二个Eureka服务器,以提高弹性,并在更新服务器时提供备用服务器。 http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html这听起来很简单:你只需要像Eureka客户端一样配置你的服务器。因此,我将其

  • 这里似乎有什么问题?

  • 我正在尝试JUnit5TestContainers快速启动示例:

  • 问题内容: 我是Socket.IO的100%新手,并且刚刚安装了它。我试图遵循一些示例,并且可以使服务器端运行,但似乎无法使客户端连接。 以下是我的server.js: 这是我的index.html 当我执行node server.js时,它指示socket.io已启动。 当我加载index.html时,出现一行,指出“调试-服务静态/socket.io.js”,但除此之外,没有控制台消息或其他行

  • 问题内容: 我正在尝试运行JavaKinesisWordCountASL示例。 该示例似乎连接到我的Kinesis Stream并从该流中获取数据(如下面的日志所示)。但是,在示例中,Sparks不会调用传递给unionStreams.flatMap方法的调用函数,并且不会打印任何单词计数。 我尝试同时使用Java 8和Java 7运行。我正在ubuntu实例上运行它。相同的示例适用于我的Macb

  • 我已经按照说明实现了facebook android cognito示例cognitosyncdemo,在尝试同步数据集时出现以下错误, E/ListDatasetsActivity(8541):原因:com.amazonaws.AmazonServiceException:检测到1验证错误:“登录”处的值“{graph.facebook.com=}”无法满足约束:映射值必须满足约束:成员的长度必